1
从this link中获取tripservice wsdl在此wsdl中,我将下面的元素替换为(添加nillable为true并添加了最小长度和最大长度限制)。vb.net soap客户端请求生成
<xs:element minOccurs="0" name="from" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="12"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
现在在我的vb.net客户我通过添加服务引用,WSDL保存到本地文件夹调用的服务。
Dim objproxy As New Tripservice.TripPriceServiceFacadeClient
Dim gh As New Tripservice.trip
gh.adults = 9
gh.duration = 8
gh.rooms = 8
gh.to = "p"
objproxy.getTripPrice(gh)
它会抛出结束点没有发现异常,但是我对请求xml感兴趣。我启用了跟踪,发现下面的请求已生成。
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<getTripPrice xmlns="http://trip.price.service">
<trip xmlns="">
<adults>9</adults>
<duration>8</duration>
<from xsi:nil="true"/>
<rooms>8</rooms>
<to>p</to>
</trip>
</getTripPrice>
</s:Body>
</s:Envelope>
从的xsi的元件:无=“真”被生成,即使我没有接触元件在我vb.net代码来生成所述请求。根据wsdl(min occurrence = 0),元素是可选的。我如何发送请求而不使用来自元素名称的请求?
在接受请求xml的Web服务中,根据标记是否存在以及它是否为nillable = true来执行一些处理。然而,如果不改变,请求总是伴随着这种行为。 – Suresh 2012-03-03 16:41:30
@Suresh,我发现合同中的一个奇怪的事情是,一次旅行的价格可能不包括*,*和a *到*。因为这些是可选的(?!),服务的文档应该告诉你,如果其中一个或另一个或两者缺失,行为应该是什么。我会联系服务所有者。还有一条建议:在任何情况下,合同的修改方式都不应该与原来的一致(引进的可能是兼容的,但不是一致的);有时需要XML Schema重构来适应工具,但在你的情况下,我不明白为什么你会摆弄它... – 2012-03-03 18:34:24