我的webservice响应的名称空间错误

时间:2017-09-27 12:29:45

标签: java web-services soap namespaces soapui

我在调用Webservice时遇到了问题。我的响应元素的名称与WSDL中的名称不同。但是对于请求,它完美地运作。

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

这是WSDL:

{
  "size": 0,
  "aggregations": {
    "costs_agg": {
      "nested": {
        "path": "costs"
      },
      "aggregations": {
        "bool_agg": {
          "must": [
            {
              "range": {
                "costs.startDate": {
                  "gte": "2017-02-14T00:00:00+00:00"
                }
              }
            },
            {
              "range": {
                "costs.endDate": {
                  "lte": "2017-02-15T00:00:00+00:00"
                }
              }
            },
            {
              "wildcard": {
                "costs.region": "useast.*"
              }
            }
          ]
        },
        "aggregations": {
          "cost_sum_agg": {
            "sum": {
              "field": "costs.cost"
            }
          }
        }
      }
    }
  }
}

这是SoapUI中的请求:

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

1 个答案:

答案 0 :(得分:0)

看起来您对请求和响应中的前缀有疑问,例如。fsb vs ns2,对吧?

只要使用相同的名称空间,使用什么前缀并不重要。如果同时查看请求和响应,则两者都指向 namespace ,即http://www.fimasys.com/fsb

您可以阅读有关名称空间here

的更多信息