WebService响应为null [英] WebService response is null

查看:91
本文介绍了WebService响应为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个客户端Web服务,当我在VS 2008中使用它时,我收到的结果对象为null.但是,当我在SOAP UI中使用相同的服务时(SOAP UI是用于测试Web服务的工具),它将发送xml结果.下面是我正在使用的代码.我什至与Web服务提供商进行了讨论,他们确认在Web服务服务器的日志中,他们能够看到从其末端发送的请求和响应.

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)


如果我在这里缺少任何物品,请告诉我.

谢谢,
Sudhir.


Please let me know if I am missing anything here.

Thanks,
Sudhir.

推荐答案

如果您打算将参数作为XML发送,则不要这样做.您正在将参数写入文件,但此后不对其执行任何操作.除此之外,我看不到您的代码有什么真正的错误(除了缺少一些空格以使其更具可读性).
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).


John,您好,

Hi John,

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


上面的代码用于我的内部测试,但是下面的代码将请求提交到Web服务


The above code is for my internal testing purpose but the below code is submitting the request to webservice

PricingRequestObj.SSIGetRenewalPriceListSrv(pricereqtype);

,并将结果对象分配给"PricingResponseObj"接收空值.

由于相同的输入正在作为Web服务测试工具的SOAP UI接收到输出,因此我怀疑这是否是反序列化中的任何问题/任何导致此问题的问题.

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.


这是修复了久违的问题,但是如果可以帮助任何人,请共享解决方案.


方法SSIGetRenewalPriceListSrv的定义输出为GetRenewalPriceResType []数据类型,但从Web服务接收的输出为GetPriceResType []数据类型.这就是输出接收为空的原因.为了实现这一目标,我们的团队成员采取了以下步骤
1.他们已将Web服务的接收输出写入一个文本文件,该文件确认输出数据类型不同.
2.更改数据类型后,我们可以接收输出.
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.


这篇关于WebService响应为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆