[英]C# Parsing Response of a Java Web Service
I am calling a Java WebLogic web service from my .Net application. 我正在从.Net应用程序调用Java WebLogic Web服务。 I have added a service reference to the jws service. 我已将服务引用添加到jws服务。
The service can be called fine and I can see the response in Fiddler, however the problem is that the propery listOfHolds
is coming as null although I can see a list of holds in the XML of the response. 可以将服务称为罚款,并且可以在Fiddler中看到响应,但是问题是,尽管我可以在响应的XML中看到保留列表,但listOfHolds
即将listOfHolds
null。
Here is the code for calling 这是调用代码
holdsList result = proxy.viewHoldsList(request.AccountNo);
int noOfHolds = result.NumberOfHolds; // This value is read fine
object[] holds = result.listOfHolds; // This is coming as Null despite the values in the response
Here is the response XML as captured by Fiddler 这是Fiddler捕获的响应XML
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<work:WorkContext xmlns:work="http://oracle.com/weblogic/soap/workarea/">rO0...AAA</work:WorkContext>
</S:Header>
<S:Body>
<ns0:viewHoldsListResponse xmlns:ns0="http://www.openuri.org/">
<ns0:viewHoldsListResult>
<ns0:TotalAmount>130.0</ns0:TotalAmount>
<ns0:NumberOfHolds>4</ns0:NumberOfHolds>
<ns0:listOfHolds>
<ns0:item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:holdDetails">
<ns0:xsiType>HoldDetails</ns0:xsiType>
<ns0:Amount>100.0</ns0:Amount>
<ns0:StartDate>2014-02-15T00:00:00.0</ns0:StartDate>
<ns0:ExpiryDate>2014-02-20T00:00:00.0</ns0:ExpiryDate>
<ns0:Description>For testing</ns0:Description>
<ns0:Instruction/>
<ns0:Tracer>00000810000287294002</ns0:Tracer>
<ns0:HoldId>3591376655</ns0:HoldId>
<ns0:EmployeeId>0</ns0:EmployeeId>
</ns0:item>
<ns0:item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:holdDetails">
<ns0:xsiType>HoldDetails</ns0:xsiType>
<ns0:Amount>10.0</ns0:Amount>
<ns0:StartDate>2014-02-15T00:00:00.0</ns0:StartDate>
<ns0:ExpiryDate>2014-02-17T00:00:00.0</ns0:ExpiryDate>
<ns0:Description>DESC</ns0:Description>
<ns0:Instruction/>
<ns0:Tracer>00000810000287294004</ns0:Tracer>
<ns0:HoldId>3591376656</ns0:HoldId>
<ns0:EmployeeId>0</ns0:EmployeeId>
</ns0:item>
</ns0:listOfHolds>
</ns0:viewHoldsListResult>
</ns0:viewHoldsListResponse>
</S:Body>
</S:Envelope>
I have faced a similar problem before and the problem was a missing xmlns
attribute on one of the tags. 我之前也遇到过类似的问题,问题是其中一个标记缺少xmlns
属性。 In this case I am suspecting the extra <ns0:xsiType>HoldDetails</ns0:xsiType>
tag that is coming under the <ns0:item>
tag. 在这种情况下,我怀疑<ns0:item>
标记下有多余的<ns0:xsiType>HoldDetails</ns0:xsiType>
<ns0:item>
标记。
Update Even after the web service provider removed the extra <xsiType>
tag, I am unable to read the listOfHolds
. 更新即使Web服务提供商删除了多余的<xsiType>
标记之后,我也无法读取listOfHolds
。
My questions are: 我的问题是:
listOfHolds
? 我可以在.Net代码中执行任何操作,以便获得listOfHolds
的预期值吗? NumberOfHolds
is being successfully read from the response but not listOfHolds
? [可选]为什么从响应中成功读取了NumberOfHolds
而不是listOfHolds
? The vendor of the web service has made a change. Web服务的供应商进行了更改。 They changed xsi:type="ns0:holdDetails"
to xsi:type="ns0:HoldDetails"
(H instead of h). 他们将xsi:type="ns0:holdDetails"
更改为xsi:type="ns0:HoldDetails"
(用H代替h)。
The point is in Java, and unlike .Net as far as I can tell, they have a control over the generated XML from the web service. 关键是在Java中,据我所知,与.Net不同,它们可以控制从Web服务生成的XML。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.