2017-09-04 73 views
1

通過在VS2013 BizTalk中使用此WDSL生成SOAP-Web代理,我遇到了問題。從WSDL生成SOAP Web代理問題BizTalk VS2013

看來VS不會生成正確的xsd和cs。當我從XSD生成實例,它看起來像這樣:

由VS生成:

<ns0:timeseriesValues xmlns:ns0="http://test.com/abc/DataService/xyz"> 
    <ns0:id>mdsId_0</ns0:id> 
    <ns0:res>day</ns0:res> 
    <ns0:quality>prognosis</ns0:quality> 
    <ns0:timeseries> 
    <ns0:time>1999-05-31T13:20:00.000-05:00</ns0:time> 
    <ns0:value>10</ns0:value> 
    </ns0:timeseries> 
    <ns0:timeseries> 
    <ns0:time>1999-05-31T13:20:00.000-05:00</ns0:time> 
    <ns0:value>10</ns0:value> 
    </ns0:timeseries> 
    <ns0:timeseries> 
    <ns0:time>1999-05-31T13:20:00.000-05:00</ns0:time> 
    <ns0:value>10</ns0:value> 
    </ns0:timeseries> 
</ns0:timeseriesValues> 

但它應該是這樣的,與WS談:

<ns0:sendTemp xmlns:ns0="http://www.test.com/DataService.xsd"> 
    <ns0:id>138846</ns0:id> 
    <ns0:res>hour</ns0:res> 
    <ns0:quality>prognosis</ns0:quality> 
    <ns0:timeseries> 
     <ns0:time>2017-08-27T23:00:00+02:00</ns0:time> 
     <ns0:value>16.7</ns0:value> 
    </ns0:timeseries> 
    <ns0:timeseries> 
     <ns0:time>2017-08-28T00:00:00+02:00</ns0:time> 
     <ns0:value>16</ns0:value> 
    </ns0:timeseries> 
</ns0:sendTemp> 

WSDL:

<?xml version='1.0' encoding='UTF-8'?> 
<wsdl:definitions 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:ns="http://www.test.com/DataService.xsd" 
    xmlns:wsc="http://www.test.com/DataService.xsd" 
    xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    targetNamespace="http://www.test.com/DataService.xsd"> 
    <wsdl:types> 
    <xs:schema 
     xmlns="http://test.com/abc/DataService/xyz" 
     attributeFormDefault="unqualified" 
     elementFormDefault="qualified" 
     targetNamespace="http://test.com/abc/DataService/xyz">  
     <xs:complexType name="timeseriesValues"> 
     <xs:sequence> 
      <xs:element name="id" type="xs:string" /> 
      <xs:element name="res"> 
      <xs:simpleType> 
       <xs:restriction base="xs:string"> 
       <xs:enumeration value="day" /> 
       <xs:enumeration value="hour" /> 
       </xs:restriction> 
      </xs:simpleType> 
      </xs:element> 
      <xs:element name="quality" minOccurs="0"> 
      <xs:simpleType> 
       <xs:restriction base="xs:string"> 
       <xs:enumeration value="prognosis"/> 
       <xs:enumeration value="allocation"/> 
       </xs:restriction> 
      </xs:simpleType>  
      </xs:element> 
      <xs:element maxOccurs="unbounded" minOccurs="0" name="timeseries"> 
      <xs:complexType> 
       <xs:sequence> 
       <xs:element name="time" type="xs:dateTime" /> 
       <xs:element name="value" type="xs:double" /> 
       </xs:sequence> 
      </xs:complexType> 
      </xs:element> 
     </xs:sequence> 
     </xs:complexType> 
    </xs:schema> 
    <xs:schema 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns="http://www.test.com/DataService.xsd" 
     xmlns:xyz="http://test.com/abc/DataService/xyz" 
     attributeFormDefault="qualified" 
     elementFormDefault="qualified" 
     targetNamespace="http://www.test.com/DataService.xsd"> 
     <xs:import namespace="http://test.com/abc/DataService/xyz" /> 
     <xs:element name="sendPreise" type="xyz:timeseriesValues" /> 
     <xs:element name="sendPreiseResponse" type="xs:anyType" /> 
     <xs:element name="sendTemp" type="xyz:timeseriesValues" /> 
     <xs:element name="sendTempResponse" type="xs:anyType" />  
    </xs:schema> 
    </wsdl:types> 
    <wsdl:message name="sendTempResponse"> 
    <wsdl:part name="sendTempResponse" element="wsc:sendTempResponse"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:message name="sendTemp"> 
    <wsdl:part name="parameters" element="ns:sendTemp"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:message name="sendPreise"> 
    <wsdl:part name="parameters" element="ns:sendPreise"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:message name="sendPreiseResponse"> 
    <wsdl:part name="sendPreiseResponse" element="wsc:sendPreiseResponse"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:portType name="event_PortType"> 
    <wsdl:operation name="sendPreise"> 
     <wsdl:input name="sendPreise" message="wsc:sendPreise"> 
     </wsdl:input> 
     <wsdl:output name="sendPreiseResponse" message="wsc:sendPreiseResponse"> 
     </wsdl:output> 
    </wsdl:operation> 
    <wsdl:operation name="sendTemp"> 
     <wsdl:input name="sendTemp" message="wsc:sendTemp"> 
     </wsdl:input> 
     <wsdl:output name="sendTempResponse" message="wsc:sendTempResponse"> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="event_Binding" type="wsc:event_PortType"> 
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="sendPreise"> 
     <wsdlsoap:operation soapAction="sendPreise" /> 
     <wsdl:input name="sendPreise"> 
     <wsdlsoap:body parts="parameters" use="literal" /> 
     </wsdl:input> 
     <wsdl:output name="sendPreiseResponse"> 
     <wsdlsoap:body parts="sendPreiseResponse" use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    <wsdl:operation name="sendTemp"> 
     <wsdlsoap:operation soapAction="sendTemp" /> 
     <wsdl:input name="sendTemp"> 
     <wsdlsoap:body parts="parameters" use="literal" /> 
     </wsdl:input> 
     <wsdl:output name="sendTempResponse"> 
     <wsdlsoap:body parts="sendTempResponse" use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="event"> 
    <wsdl:port name="event_Port" binding="wsc:event_Binding"> 
     <wsdlsoap:address location="http://TEST:80/WS/" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

這是一個錯誤,或可以告訴我爲什麼這樣做?

這是根元素名稱我的意思。

時間序列值

sendTemp或sendPreise。

該請求是「sendTemp」或「sendPreise」,但然後我得到序列化問題。

模式定義:sendPreise類型= timeseriesvalues sendTemp類型= timeseriesvalues

但是,只有 「timeseriesvalues」 作爲根元素名稱的工作原理。

+0

究竟是什麼你的問題是什麼?該id被定義爲一個字符串,因此在生成實例時的行爲與預期相同。其他領域是什麼問題? – Dijkgraaf

+0

如果我使用我向您回答的選項(添加>添加生成的項目>使用WCF服務)生成實例,它會生成此XML xyz:id_0 ... In this not what you need? – felixmondelo

回答

0

我沒有看到任何錯誤。

在XML命名空間是按照的targetNamespace在WSDL "http://test.com/abc/DataService/xyz"

的ID被定義爲在WSDL的字符串,因此架構。所以當它生成它時,它會生成一個字符串示例。

res被定義爲日或小時,所以這也是正確的。

值時間序列下被定義爲雙(不是int),所以這是它產生作爲一個例子

時間是日期時間,這是它是將所生成的樣本。

0

如果從添加BizTalk項目添加WSDL>添加生成項目>使用WCF服務,您將得到XSD,只要你想:

enter image description here