Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WebService
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.
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
GetRenewalPriceResType[] SSIGetRenewalPriceListSrvService.SSIGetRenewalPriceListSrv(GetRenewalPriceReqType[] SSIGetRenewalPriceListSrvReq)
Please let me know if I am missing anything here.
 
Thanks,
Sudhir.
Posted 28-Dec-11 21:48pm
Edited 29-Dec-11 3:23am
v3
Comments
Bojjaiah at 29-Dec-11 3:41am
   
can you send me entire code? will see what's exact errore.
SudhirDev at 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);
}
}
}
}
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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).
  Permalink  
Comments
Espen Harlinn at 30-Dec-11 6:43am
   
Good reply :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi John,
 
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
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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100