Click here to Skip to main content
15,895,782 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,

I have a client webservice, when I consume it in VS 2008 I receive the result object as null. But when I use the same service in the SOAP UI(SOAP UI is a tool to test the webservices) it sends the xml result. Below is the code that I am using. I even discussed with the webservice provider and they confirmed that in the logs of the webservice server they are able to see the request and response send from their end.
C#
GetRenewalPriceReqType[] pricereqtype = new GetRenewalPriceReqType[1];
                ProgressPriceAPI.SSIGetRenewalPriceListSrvService PricingRequestObj = new SSIGetRenewalPriceListSrvService();
                ProgressPriceAPI.GetRenewalPriceResType[] PricingResponseObj ;
                ProgressPriceAPI.GetRenewalTaxType[] txprice;
                pricereqtype[0] = new GetRenewalPriceReqType();
                pricereqtype[0].Domain = "USA";
                pricereqtype[0].ContractNumber = "153452";
                pricereqtype[0].ContractLine = 5;
                pricereqtype[0].AdjustPriceRenewal = "A";
                pricereqtype[0].ServiceLevel = "STDNEW";
                pricereqtype[0].TaxBasisAmount = 0;
                pricereqtype[0].ContractLineSpecified = true;
                pricereqtype[0].EffectiveDateSpecified = true;
                pricereqtype[0].TaxBasisAmountSpecified = true;
                string strDate = "2011-11-30";
                DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
                dtfi.ShortDatePattern = "YYYY-MM-DD";
                dtfi.DateSeparator = "-";
                DateTime objDate = Convert.ToDateTime(strDate, dtfi);
                pricereqtype[0].EffectiveDate = objDate;
                ObjectToXml(pricereqtype[0], "c:\\pricereqtype.xml");
                //PricingResponseObj = new GetRenewalPriceResType[2];
                PricingResponseObj = PricingRequestObj.SSIGetRenewalPriceListSrv(pricereqtype);

The signature is as below
C#
GetRenewalPriceResType[] SSIGetRenewalPriceListSrvService.SSIGetRenewalPriceListSrv(GetRenewalPriceReqType[] SSIGetRenewalPriceListSrvReq)

Please let me know if I am missing anything here.

Thanks,
Sudhir.
Posted
Updated 29-Dec-11 2:23am
v3
Comments
Bojjaiah 29-Dec-11 3:41am    
can you send me entire code? will see what's exact errore.
SudhirDev 29-Dec-11 4:09am    
Below is the entire code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//using PriceAPI.ProgressPriceAPI;
using System.Globalization;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Text;
using PriceAPI.ProgressPriceAPI ;
namespace PriceAPI
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
try
{

CultureInfo clf = new CultureInfo("en-US");

GetRenewalPriceReqType[] pricereqtype = new GetRenewalPriceReqType[1];
ProgressPriceAPI.SSIGetRenewalPriceListSrvService PricingRequestObj = new SSIGetRenewalPriceListSrvService();
ProgressPriceAPI.GetRenewalPriceResType[] PricingResponseObj ;
ProgressPriceAPI.GetRenewalTaxType[] txprice;
//txprice = new GetRenewalTaxType[1];
pricereqtype[0] = new GetRenewalPriceReqType();
pricereqtype[0].Domain = "USA";
pricereqtype[0].ContractNumber = "153452";
pricereqtype[0].ContractLine = 5;
pricereqtype[0].AdjustPriceRenewal = "A";
pricereqtype[0].ServiceLevel = "STDNEW";
pricereqtype[0].TaxBasisAmount = 0;

pricereqtype[0].ContractLineSpecified = true;
pricereqtype[0].EffectiveDateSpecified = true;
pricereqtype[0].TaxBasisAmountSpecified = true;
string strDate = "2011-11-30";
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.ShortDatePattern = "YYYY-MM-DD";
dtfi.DateSeparator = "-";
DateTime objDate = Convert.ToDateTime(strDate, dtfi);

pricereqtype[0].EffectiveDate = objDate;
ObjectToXml(pricereqtype[0], "c:\\pricereqtype.xml");
//PricingResponseObj = new GetRenewalPriceResType[2];

PricingResponseObj = PricingRequestObj.SSIGetRenewalPriceListSrv(pricereqtype);
Label1.Text = "Success";


}
catch (Exception ex) {
Label1.Text = ex.Message;
}

}

private void GetPrice()
{
//ProgressPriceAPI.
}

public static void ObjectToXml(object obj, string path_to_xml)
{
//serialize and persist it to it's file
try
{

System.Xml.Serialization.XmlSerializer writer =
new System.Xml.Serialization.XmlSerializer(obj.GetType());
System.IO.StreamWriter file =
new System.IO.StreamWriter(path_to_xml);

writer.Serialize(file, obj);
file.Close();
//XmlSerializer ser = new XmlSerializer(obj.GetType());
//FileStream fs = File.Open(
// path_to_xml,
// FileMode.OpenOrCreate,
// FileAccess.Write,
// FileShare.ReadWrite);
//ser.Serialize(fs, obj);
}
catch (Exception ex)
{
throw new Exception(
"Could Not Serialize object to " + path_to_xml,
ex);
}
}
}
}

If your intent is to send the parameters as XML, you're not doing that. You're writing the parameters to a file, but not doing anything with it after that. beyond that, I see nothing really wrong with your code (other than missing some whitespace to make it a little more readable).
 
Share this answer
 
Comments
Espen Harlinn 30-Dec-11 6:43am    
Good reply :)
Hi John,

C#
ObjectToXml(pricereqtype[0], "c:\\pricereqtype.xml");

The above code is for my internal testing purpose but the below code is submitting the request to webservice
C#
PricingRequestObj.SSIGetRenewalPriceListSrv(pricereqtype);
and the result object is assigned to "PricingResponseObj" which is receiving the null value.

As the same input is receiving an output in the SOAP UI which is a webservice test tool, I was suspecting if ther is any issue in deserialization/any which is causing this issue.
 
Share this answer
 
v2
This is fixed long back but sharing the solution if this could help anyone.


The defined output of the method SSIGetRenewalPriceListSrv was GetRenewalPriceResType[] datatype but the received output from webservice was GetPriceResType[] datatype. That was the reason the output was receiving as null. To idnetify this our team members has approached below steps
1. They have written the received output from webservice to a text file, which confirmed that the output data type is different.
2. When we changed datatype, we were able to receive the output.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900