刚接触SOAP / WSDL(以及一个相当差的程序员),我正在尝试构建一个返回以下XML消息的简单服务:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://www.x.se/object/1"
xmlns:ns2="http://www.x.se/object/2">
<SOAP-ENV:Body>
<ns1:objectreport>
<ns2:time>the time</ns2:time>
</ns1:objectreport>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但是,我无法将数据从时间添加到“ns2”命名空间(即返回时间标记而没有ns2前缀),并且当前的WSDL返回以下内容:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://www.x.se/object/1"
xmlns:ns2="http://www.x.se/object/2">
<SOAP-ENV:Body>
<ns1:objectreport>
<time>the time</time>
</ns1:objectreport>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
非常感谢任何帮助
/彼得
WSDL文件:
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.x.se/webservice/test/"
xmlns: ns_1="http://www.x.se/object/1"
xmlns:ns_2="http://www.x.se/object/2"
targetNamespace="http://www.x.se/webservice/test/"
name="Test">
<types>
<xs:schema targetNamespace="http://www.x.se/object/1">
<xs:element name="getobject">
<xs:complexType>
<xs:sequence>
<xs:element name="test_string" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="objectreport" >
<xs:complexType>
<xs:sequence>
<element name="time" type="ns_2:time_t" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema targetNamespace="http://www.x.se/object/2">
<xs:element name="time_t" >
<xs:complexType>
<xs:sequence>
<element name="time" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<message name="getobjectRequest">
<part name="getobject" element="ns_1:getobject"/>
</message>
<message name="getobjectResponse">
<part name="objectreport" element="ns_1:objectreport"/>
</message>
<portType name="getdataType">
<operation name="getobject">
<input message="tns:getobjectRequest"/>
<output message="tns:getobjectResponse"/>
</operation>
</portType>
<binding name="getdataBinding" type="tns:getdataType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getobject">
<soap:operation soapAction="getdataService#data"/>
<input name="getobjectRequest">
<soap:body use="literal" />
</input>
<output name="getobjectResponse">
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="getdataService">
<port name="getdataPort" binding="getdataBinding">
<soap:address location="http://www.x.se/webservice/test/server.php"/>
</port>
</service>
</definitions>
答案 0 :(得分:0)
请在您的架构中添加此属性 - elementFormDefault =&#34; qualified&#34;。您可以在所有架构声明中添加它。
<xs:schema targetNamespace="http://www.x.se/object/2" elementFormDefault="qualified">
<xs:element name="time_t" >
<xs:complexType>
<xs:sequence>
<element name="time" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>