从WSDL生成的XML请求始终添加命名空间

时间:2018-01-12 22:09:53

标签: xml web-services soap ant wsdl

我遇到的问题是,从WSDL生成的请求总是将一个名称空间附加到Soap Body元素向下一步的元素。我们使用Apache Ant和wsimport命令来生成相关的java文件。

收件人希望请求采用以下格式:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope
    xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <OTMSS>
            <username>username</username>
            <password>password</password>
            <OtherStuff>
                foo
            </OtherStuff>
        </OTMSS>
    </S:Body>
</S:Envelope>

但是他们提供的WSDL:

<?xml version="1.0"?>
<wsdl:definitions name="SS" targetNamespace="http://xmlns.oracle.com/SS_jws/SS/SS"
                  xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
                  xmlns:ns="http://xmlns.oracle.com/apps/otm"
                  xmlns:client="http://xmlns.oracle.com/SS_jws/SS/SS"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>
    <wsdl:documentation>
        <abstractWSDL>http://customer:8001/soa-infra/services/default/SS!1.0/SS.wsdl</abstractWSDL>
    </wsdl:documentation>
    <wsdl:types>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified">
          <xs:element name="OTMSS" type="OTMSSType"/>
          <xs:element name="OtherStuff" type="otherStuffList"/>
          <xs:complexType name="OTMSSType">
              <xs:sequence>
                  <xs:element minOccurs="0" name="username" type="xs:string"/>
                  <xs:element minOccurs="0" name="password" type="xs:string"/>
                  <xs:element name="OtherStuff" type="otherStuffList"/>
              </xs:sequence>
          </xs:complexType>
          <xs:complexType name="otherStuffList">
              <xs:sequence>
                  foo
              </xs:sequence>
          </xs:complexType>
      </xs:schema>
    </wsdl:types>
    <wsdl:message name="SSRequestMessage">
        <wsdl:part name="payload" element="OTMSS"/>
    </wsdl:message>
    <wsdl:message name="SSResponseMessage">
        <wsdl:part name="payload" element="OTMSS"/>
    </wsdl:message>
    <wsdl:portType name="SS">
        <wsdl:operation name="process">
            <wsdl:input message="client:SSRequestMessage"/>
            <wsdl:output message="client:SSResponseMessage"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="SSBinding" type="client:SS">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="process">
            <soap:operation soapAction="process" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SS_client_ep">
        <wsdl:port name="SS_pt" binding="client:SSBinding">
            <soap:address location="https://customerEndpoint:9443/Company/services/SS_client_ep/"/>
        </wsdl:port>
    </wsdl:service>
    <plnk:partnerLinkType name="SS">
        <plnk:role name="SSProvider">
            <plnk:portType name="client:SS"/>
        </plnk:role>
    </plnk:partnerLinkType>
</wsdl:definitions>

似乎总是将命名空间附加到OTMSS元素,如下所示:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope
    xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:OTMSS
            xmlns:ns2="http://xmlns.oracle.com/SS_jws/SS/SS">
            <username>username</username>
            <password>password</password>
            <OtherStuff>
                foo
            </OtherStuff>
        </ns2:OTMSS>
    </S:Body>
</S:Envelope>

我的问题是WSDL中需要更改什么才能完全删除此命名空间?当通过SoapUI生成请求时,它看起来像客户想要的那样,但是当通过Ant生成时,它似乎总是默认该元素的命名空间。

在我的故障排除过程中,我一直在尝试编辑wsdl并重新生成构建xml的源以更正此问题,但似乎总是填充默认命名空间。我删除了对&的每个引用#34;客户机&#34;来自WSDL的前缀及其关联的命名空间,但请求中的OTMSS元素的命名空间看起来像“ns2:OTMSS xmlns =&#34; FolderStructure / ThatHouses / TheJavaFiles / InReverse&#34;&gt;&# 39 ;.很奇怪。

0 个答案:

没有答案