【问题标题】:Wrong namespace for my webservice response我的网络服务响应的命名空间错误
【发布时间】:2018-03-08 22:38:13
【问题描述】:

我在调用 Web 服务时遇到问题。我的响应元素的名称与 WSDL 中的名称不同。但是对于请求,它可以完美运行。

你对此有什么想法吗?我觉得不同的名字很好。

这是 WSDL:

    <?xml version="1.0" encoding="UTF-8"?>
<definitions name="test-existence-muna-service"
   targetNamespace="http://www.fimasys.com/fsb"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="http://www.fimasys.com/fsb"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <types>
        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.fimasys.com/fsb">
            <element name="TestExistenceMuna_Input_Message">
                <complexType>
                    <sequence>
                        <element minOccurs="1" name="muna" type="string"/>
                    </sequence>
                </complexType>
            </element>
            <element name="TestExistenceMuna_Output_Message">
                <complexType>
                    <sequence>
                        <element minOccurs="1" name="existenceMuna" type="boolean"/>
                    </sequence>
                </complexType>
            </element>
        </schema>
    </types>

    <message name="TestExistenceMuna_Input_Message">
        <part name="parameters" element="tns:TestExistenceMuna_Input_Message"></part>
    </message>
    <message name="TestExistenceMuna_Output_Message">
        <part name="parameters" element="tns:TestExistenceMuna_Output_Message"></part>
    </message>

    <portType name="testExistenceMunaPortType">
        <operation name="getExistenceMuna">
            <input message="tns:TestExistenceMuna_Input_Message" />
            <output message="tns:TestExistenceMuna_Output_Message" />
        </operation>
    </portType>

    <binding name="testExistenceMunaBinding" type="tns:testExistenceMunaPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="getExistenceMuna">
            <soap:operation soapAction="http://www.fimasys.com/fsb/getExistenceMuna" />
            <input>
                <soap:body use="literal" />
            </input>
            <output>
                <soap:body use="literal" />
            </output>
        </operation>
    </binding>

    <service name="test-existence-muna-service">
        <port binding="tns:testExistenceMunaBinding" name="testExistenceMunaPort">
          <soap:address location="http://0.0.0.0:8088/fsb/test-existence-muna-service/"/>
        </port>
    </service>
</definitions>

这是 SoapUI 中的请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fsb="http://www.fimasys.com/fsb">
   <soapenv:Header/>
   <soapenv:Body>
      <fsb:TestExistenceMuna_Input_Message>
         <muna>07282166.12</muna>
      </fsb:TestExistenceMuna_Input_Message>
   </soapenv:Body>
</soapenv:Envelope>

这是 SoapUI 中的响应:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getExistenceMunaResponse xmlns:ns2="http://www.fimasys.com/fsb">
         <existenceMuna>true</existenceMuna>
      </ns2:getExistenceMunaResponse>
   </soap:Body>
</soap:Envelope>

【问题讨论】:

  • 您的响应元素不是在 wsdl 的某处被引用为 getExixtenceMunaResponse 吗?你能显示你的 wsdl 文件吗?
  • 感谢您的回答。我编辑了原始帖子。
  • 您也可以访问实施吗?是不是有一些包装器或什么导致元素被重命名?
  • 嗯,调用的方法就像@WebResult(name = "existenceMuna") public Boolean getExistenceMuna(@WebParam(name = "muna") String muna) throws FMSException;
  • 您是如何创建该 WS 的?先契约还是先代码?你在使用一些框架吗?如果你重命名方法名会有什么变化吗?

标签: java web-services soap namespaces soapui


【解决方案1】:

看起来您对请求和响应中的前缀有疑问,即fsbns2,对吧?

使用什么前缀无关紧要,只要它使用相同的命名空间。如果您同时查看请求和响应,它们都指向 namespace,即http://www.fimasys.com/fsb

你可以阅读更多关于命名空间here

【讨论】:

  • 好的,谢谢。我真正的问题是 WSDL,我的响应设置为 但soapui 给了我一个 fimasys.com/fsb"> 代替...输入可以通过方式,在 WSDL 和 soapui 中是
猜你喜欢
  • 2015-07-25
  • 2012-03-13
  • 2011-01-05
  • 1970-01-01
  • 2019-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-23
相关资源
最近更新 更多