指定元素的默认命名空间

时间:2013-05-24 20:41:06

标签: soap namespaces wsdl

我正在构建服务以接受以下消息。请注意InformationExchangePackage如何没有名称空间前缀,但采用默认的xmlns =“http://www.something.com/dir/1.0.9”。我无法弄清楚如何在WSDL中创建这种行为。

我想要服务的SOAP请求:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Body>
    <InformationExchangePackage xmlns:j="http://www.something.gov/dir/3.0.3" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://www.something.com/dir/1.0.9">
       <j:OtherInformation>Sometext</OtherInformation>
    </InformationExchangePackage>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

以下是soapUI生成的SOAP请求。注意InformationExchangePackage上的“loc”前缀(不是我想要的)。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:loc="http://localhost/">
   <soapenv:Header/>
   <soapenv:Body>
      <loc:process>
         <loc:InformationExchangePackage>
            <OtherInformation>?</OtherInformation>
         </loc:InformationExchangePackage>
      </loc:process>
   </soapenv:Body>
</soapenv:Envelope>

我目前的WSDL:

<?xml version="1.0" encoding="ISO-8859-1"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:tns="http://localhost/"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:cs="http://www.w3.org/2001/XMLSchema"
                  targetNamespace="http://localhost/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <wsdl:types>
        <xs:schema targetNamespace="http://localhost/">
            <xs:element name="InformationExchangePackage">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="OtherInformation" type="xs:anyType"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="processResponseType">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element type="xs:string" name="aCode"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl:types>


    <wsdl:message name="processRequest">
        <wsdl:part name="InformationExchangePackage" element="tns:InformationExchangePackage"/>
    </wsdl:message>
    <wsdl:message name="processResponse">
        <wsdl:part name="processResponse" element="tns:processResponseType"/>
    </wsdl:message>

    <wsdl:portType name="CCHEndpoint">
        <wsdl:operation name="process">
            <wsdl:input message="tns:processRequest"/>
            <wsdl:output message="tns:processResponse"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="CCHBinding" type="tns:CCHEndpoint">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>

        <wsdl:operation name="process">
            <soap:operation soapAction="urn:process" style="rpc"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="CCHEndpointService">
        <wsdl:port name="OrderService" binding="tns:CCHBinding">
            <!--<soap:address location="http://localhost:8080/wildcat"/>-->
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

如果我使用loc前缀提交请求,则可以正常工作。如果我提交没有loc前缀的请求,我会得到:

org.apache.cxf.interceptor.Fault: Message part {http://www.something.com/dir/1.0.9}InformationExchangePackage was not recognized.  (Does it exist in service WSDL?)

我想我在WSDL中缺少一个参数。我在黑暗中拍摄了以下镜头,但无济于事:

<xs:element name="InformationExchangePackage" xsi:schemaLocation="http://www.something.com/dir/1.0.9">
<xs:element name="InformationExchangePackage" xsi:noNamespaceSchemaLocation="http://www.something.com/dir/1.0.9">

1 个答案:

答案 0 :(得分:0)

您没有定义任何wsdl:message块。