Soap 需要帮助在WSDL文件中定义自定义名称空间吗

Soap 需要帮助在WSDL文件中定义自定义名称空间吗,soap,wsdl,Soap,Wsdl,作为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> <n

作为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>

请在您的模式中添加此属性-elementFormDefault=qualified。您可以在所有模式声明中添加此项

<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>