dso15221 2009-07-15 20:01
浏览 49
已采纳

将名称空间从SOAP信封根目录移动到xml负载

I've got a soap envelope that is returned from a encoded RPC PHP service that I wrote that declares a namespace in the root node of the SOAP envelope. However, I want that namespace to be in the root node of the xml payload in the SOAP body. Basically, I want this:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="http://sample.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org
/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:ServiceResponse>
       <outgoingVar1>true</outgoingVar1>
    </ns1:ServiceResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

to become this:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org
/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-
ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ServiceResponse xmlns="http://sample.com">
       <outgoingVar1>true</outgoingVar1>
    </ServiceResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

and here is my annotated (left out trivial namespace declarations) WSDL as it stands right now:

<wsdl:definitions name="IJLSoapResponse" targetNamespace="http://casey.com" tns="http://casey.com" xmlns:samp="http://sample.com" ...>
<wsdl:types>
    <xsd:schema targetNamespace="http://casey.com" ...>
        <xsd:element name="incomingVar1" type="xsd:string" nillable="true"/>
        <xsd:element name="incomingVar2" type="xsd:string" nillable="true"/>
    </xsd:schema>
    <xsd:schema targetNamespace="http://sample.com" ...>
        <xsd:element name="outgoingVar1" type="xsd:boolean" nillable="true"/>
    </xsd:schema>
</wsdl:types>
<wsdl:message name="ServiceInput">
    <wsdl:part name="incomingVar1" element="tns:incomingVar1"/>
    <wsdl:part name="incomingVar2" element="tns:incomingVar2"/>
</wsdl:message>
<wsdl:message name="ServiceOutput">
    <wsdl:part name="outgoingVar1" element="samp:outgoingVar1"/>
</wsdl:message>
<wsdl:portType name="ServicePortType">
    <wsdl:operation name="ServiceMessage" parameterOrder="incomingVar1 incomingVar2">
        <wsdl:input name="ServiceMessageRequest" message="tns:ServiceInput"/>
        <wsdl:output name="ServiceMessageResponse" message="tns:ServiceOutput"/>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceBinding" type="tns:ServicePortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="ServiceMessage">
        <soap:operation soapAction="http://casey.com/soap/Service"/>
        <wsdl:input name="ServiceRequest">
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://casey.com"/>
        </wsdl:input>
        <wsdl:output name="ServiceResponse">
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://sample.com"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="ServiceService">
    <wsdl:port name="ServicePort" binding="tns:ServiceBinding">
        <soap:address location="http://casey.com/soap/Service"/>
    </wsdl:port>
</wsdl:service>
</wsdl:definitions>

Is there something in the WSDL that can be changed in order to force that namespace into the payload? I've tried moving it around to several different places to no avail. Thanks for your help.

PS If you see something wrong with the WSDl as far as it not being validating or something similar, just disregard it...the original validates/deploys/works fine. I'm more worried about where I can put the namespace. Thanks!

  • 写回答

1条回答 默认 最新

  • dongwuwan5646 2009-07-15 20:07
    关注

    It should not matter where the namespace is declared unless the code that's consuming your SOAP message is doing something wrong.

    Since both "before" and "after" examples are functionally equivalent, they are both correct with respect to WSDL, so changing WSDL is not going to have any effect in this respect.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看