来自SVCUTIL生成的类的SOAP响应与预期的响应不匹配-WCF [英] SOAP Response from SVCUTIL generated class does not match Expected Response - WCF

查看:65
本文介绍了来自SVCUTIL生成的类的SOAP响应与预期的响应不匹配-WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,这是我第一次使用WCF和使用WSDL.我使用WSDL中的SVCUTIL生成了WCF代理类:

Hello, this is my first time working with WCF and using a WSDL.  I generated a WCF proxy class using SVCUTIL from the WSDL:

http://dealer.aermanufacturing.com/getInventoryStatus.asmx?wsdl

http://dealer.aermanufacturing.com/getInventoryStatus.asmx?wsdl

当我测试服务时,我的答复是:

When I test the service my response is:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">   <soap:Body>      <getInventoryStatusResponse xmlns="http://dealer.aermanufacturing.com/getInventoryStatus.asmx">         <getInventoryStatusResult>            <Result>               <InStock></InStock>               <EstDeliveryDate></EstDeliveryDate>               <EstDeliveryTime></EstDeliveryTime>               <DeliveryLocation></DeliveryLocation>            </Result>         </getInventoryStatusResult>      </getInventoryStatusResponse>   </soap:Body></soap:Envelope>

不过,预期的响应是:

soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <getInventoryStatusResponse xmlns="http://www.aermanufacturing.com/AERInventoryCheck/">
         <getInventoryStatusResult>
            <xs:schema id="AER_x0020_Inventory" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
               <xs:element name="AER_x0020_Inventory" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
                  <xs:complexType>
                     <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="Inventory">
                           <xs:complexType>
                              <xs:sequence>
                                 <xs:element name="InStock" type="xs:string" minOccurs="0"/>
                                 <xs:element name="EstDeliveryDate" type="xs:string" minOccurs="0"/>
                                 <xs:element name="EstDeliveryTime" type="xs:string" minOccurs="0"/>
                                 <xs:element name="DeliveryLocation" type="xs:string" minOccurs="0"/>
                              </xs:sequence>
                           </xs:complexType>
                        </xs:element>
                     </xs:choice>
                  </xs:complexType>
               </xs:element>
            </xs:schema>
            <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
               <AER_x0020_Inventory xmlns="">
                  <Inventory diffgr:id="Inventory1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
                     <InStock/>
                     <EstDeliveryDate/>
                     <EstDeliveryTime/>
                     <DeliveryLocation/>
                  </Inventory>
               </AER_x0020_Inventory>
            </diffgr:diffgram>
         </getInventoryStatusResult>
      </getInventoryStatusResponse>
   </soap:Body>
</soap:Envelope>

 

为什么会出现差异,我该如何解决?  使用SVCUTIL时,我会错误地生成代理类吗?我试图避免对响应进行硬编码.  

 

Why the discrepancy and how do I fix it?  Am I generating the proxy class incorrectly when using SVCUTIL?  I am try to avoid hard-coding the response.  

谢谢

推荐答案

您如何获得预期的响应?您能否与我们分享您需要"xs:schema"作为回应的原因?在我的选择中,应在wsdl中定义它,而无需在响应中进行定义.

How did you get expected response? Could you share us the reason you need "xs:schema" in response? In my option, it should be defined in wsdl, and there is no need to define in response.

通过"http://dealer.aermanufacturing.com/getInventoryStatus.asmx?op=getInventoryStatus"检查服务请求和响应的演示,也没有这些部分.

Checking the demo of request and response for your service by "http://dealer.aermanufacturing.com/getInventoryStatus.asmx?op=getInventoryStatus", there are no these parts either.

预期结果如下,与SVCUTIL客户端的响应类似.

The expected results are below and which is similar to the response from SVCUTIL client.

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <getInventoryStatusResponse xmlns="http://dealer.aermanufacturing.com/getInventoryStatus.asmx">
      <getInventoryStatusResult>
        <anyType>
          <InStock>string</InStock>
          <EstDeliveryDate>string</EstDeliveryDate>
          <EstDeliveryTime>string</EstDeliveryTime>
          <DeliveryLocation>string</DeliveryLocation>
        </anyType>
        <DealerCode>string</DealerCode>
        <SupplierCode>string</SupplierCode>
        <PartNumber>string</PartNumber>
        <Quantity>string</Quantity>
        <WarehouseLocation>string</WarehouseLocation>
      </getInventoryStatusResult>
    </getInventoryStatusResponse>
  </soap:Body>
</soap:Envelope>

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <getInventoryStatusResponse xmlns="http://dealer.aermanufacturing.com/getInventoryStatus.asmx">
      <getInventoryStatusResult>
        <anyType>
          <InStock>string</InStock>
          <EstDeliveryDate>string</EstDeliveryDate>
          <EstDeliveryTime>string</EstDeliveryTime>
          <DeliveryLocation>string</DeliveryLocation>
        </anyType>
        <DealerCode>string</DealerCode>
        <SupplierCode>string</SupplierCode>
        <PartNumber>string</PartNumber>
        <Quantity>string</Quantity>
        <WarehouseLocation>string</WarehouseLocation>
      </getInventoryStatusResult>
    </getInventoryStatusResponse>
  </soap12:Body>
</soap12:Envelope>


这篇关于来自SVCUTIL生成的类的SOAP响应与预期的响应不匹配-WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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