Вопрос новичка - преобразование моего примера soap1.1 в soap1.2 - PullRequest
0 голосов
/ 19 сентября 2019

У меня есть служба мыла Springboot и мыльный клиент, совместимый с soap1.1, и работает нормально.Я хочу перенести это на soap1.2 сейчас.Итак, я погуглил и обнаружил, что мне нужно создать бин MessageFactory, который будет поддерживать протокол soap1.2.Поэтому я добавил это в свою конфигурацию.

@Bean
    public SaajSoapMessageFactory messageFactory() throws SOAPException {
        SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
        messageFactory.setMessageFactory(MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL));
        return messageFactory;
    }

Мой сервис мыла все еще принимает / отправляет soap1.1.

1) Мой WSDL не изменился. Итак, япошел дальше и изменил его вручную, чтобы включить soap1.2
2) я добавил MessageFactory в службу клиент / сервер

3) какие еще изменения я должен сделать, чтобы отменить запрос soap1.2?

 **SERVER LOGS --- My server is still getting text/xml**     com.sun.xml.messaging.saaj.soap.SOAPVersionMismatchException: Cannot create message: 
    incorrect content-type for SOAP version. Got: text/xml; charset=utf-8 Expected: application/soap+xml
            at 
**CLIENT LOGS show that both 1.2 and 1.1 factory classes were available**
[           main] o.s.ws.soap.saaj.SaajSoapMessageFactory  : Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
[           main] o.s.ws.soap.saaj.SaajSoapMessageFactory  : Using MessageFactory class [com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
[           main] o.s.ws.soap.saaj.SaajSoapMessageFactory  : Using MessageFactory class [com.sun.xml.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl]

.................... Обратите внимание, что мой запрос soapUI работает.Так что я что-то упускаю в мыльном клиенте

<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" 
xmlns:tri="http://www.example.com/test/"> 
<soap12:Header/> 
<soap12:Body> 
<tri:getAllCountryRequest/> 
</soap12:Body>
</soap12:Envelope>

............................................................................... WSDL

<wsdl:definitions
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://www.myexample.com/triad/"
    targetNamespace="http://www.myexample.com/triad/">
    <!-- xmlns:sch="http://www.myexample.com/triad/"-->

    <wsdl:types>
        <xs:schema elementFormDefault="qualified" targetNamespace="http://www.myexample.com/triad/">
            <xs:element name="getCountryRequest">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="name" type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="getCountryResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="countryDetails"
                            type="tns:countryDetails" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:complexType name="countryDetails">
                <xs:sequence>
                    <xs:element name="name" type="xs:string" />
                    <xs:element name="population" type="xs:int" />
                    <xs:element name="capital" type="xs:string" />
                    <xs:element name="currency" type="tns:currency" />
                </xs:sequence>
            </xs:complexType>
            <xs:simpleType name="currency">
                <xs:restriction base="xs:string">
                    <xs:enumeration value="GBP" />
                    <xs:enumeration value="INR" />
                    <xs:enumeration value="PLN" />
                </xs:restriction>
            </xs:simpleType>
            <xs:element name="getAllCountryRequest">
                <xs:complexType>
                </xs:complexType>
            </xs:element>
            <xs:element name="getAllCountryResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element maxOccurs="unbounded" name="countryDetails"
                            type="tns:countryDetails" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="getDeleteCountryRequest">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="name" type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="getDeleteCountryResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="status" type="tns:status" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="postUpdateCountryRequest">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="name" type="xs:string" />
                        <xs:element name="newCapital" type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="postUpdateCountryResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="countryDetails"
                            type="tns:countryDetails" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:simpleType name="status">
                <xs:restriction base="xs:string">
                    <xs:enumeration value="SUCCESS" />
                    <xs:enumeration value="FAILURE" />
                </xs:restriction>
            </xs:simpleType>
        </xs:schema>
    </wsdl:types>


     <!-- Request Response message -->
    <wsdl:message name="getDeleteCountryRequest">
        <wsdl:part element="tns:getDeleteCountryRequest" name="getDeleteCountryRequest">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="getDeleteCountryResponse">
        <wsdl:part element="tns:getDeleteCountryResponse" name="getDeleteCountryResponse">
        </wsdl:part>
    </wsdl:message>

    <wsdl:message name="postUpdateCountryRequest">
        <wsdl:part element="tns:postUpdateCountryRequest"  name="postUpdateCountryRequest">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="postUpdateCountryResponse">
        <wsdl:part element="tns:postUpdateCountryResponse" name="postUpdateCountryResponse">
        </wsdl:part>
    </wsdl:message>

    <wsdl:message name="getCountryRequest">
        <wsdl:part element="tns:getCountryRequest"  name="getCountryRequest">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="getCountryResponse">
        <wsdl:part element="tns:getCountryResponse" name="getCountryResponse">
        </wsdl:part>
    </wsdl:message>

    <wsdl:message name="getAllCountryRequest">
        <wsdl:part element="tns:getAllCountryRequest" name="getAllCountryRequest">
        </wsdl:part>
    </wsdl:message> 
    <wsdl:message name="getAllCountryResponse">
        <wsdl:part element="tns:getAllCountryResponse"  name="getAllCountryResponse">
        </wsdl:part>
    </wsdl:message>

    <!--  Fault message
    <wsdl:message name="UserDefinedException">   <wsdl:part name="fault" element="tns:UserDefinedFault"/>
    </wsdl:message> -->

    <wsdl:portType name="CountriesPortSoap12">
        <wsdl:operation name="getDeleteCountry">
            <wsdl:input message="tns:getDeleteCountryRequest" name="getDeleteCountryRequest">
            </wsdl:input>
            <wsdl:output message="tns:getDeleteCountryResponse" name="getDeleteCountryResponse">
            </wsdl:output>
            <!--  <wsdl:fault name="UserDefinedFault" message="tns:UserDefinedException"/> -->
        </wsdl:operation>
        <wsdl:operation name="postUpdateCountry">
            <wsdl:input message="tns:postUpdateCountryRequest"  name="postUpdateCountryRequest">
            </wsdl:input>
            <wsdl:output message="tns:postUpdateCountryResponse" name="postUpdateCountryResponse">
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getCountry">
            <wsdl:input message="tns:getCountryRequest" name="getCountryRequest">
            </wsdl:input>
            <wsdl:output message="tns:getCountryResponse" name="getCountryResponse">
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getAllCountry">
            <wsdl:input message="tns:getAllCountryRequest" name="getAllCountryRequest">
            </wsdl:input>
            <wsdl:output message="tns:getAllCountryResponse" name="getAllCountryResponse">
            </wsdl:output>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="CountriesPortSoap12" type="tns:CountriesPortSoap12">
        <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />

        <wsdl:operation name="getDeleteCountry">
            <soap12:operation/>
            <wsdl:input name="getDeleteCountryRequest">
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="getDeleteCountryResponse">
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>

        <wsdl:operation name="postUpdateCountry">
            <soap12:operation/>
            <wsdl:input name="postUpdateCountryRequest">
                <soap12:body use="literal" />
            </wsdl:input>
            <wsdl:output name="postUpdateCountryResponse">
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>

        <wsdl:operation name="getCountry">
            <soap12:operation/>
            <wsdl:input name="getCountryRequest">
                <soap12:body use="literal" />
            </wsdl:input>
            <wsdl:output name="getCountryResponse">
                <soap12:body use="literal" />
            </wsdl:output>
        </wsdl:operation>

        <wsdl:operation name="getAllCountry">
            <soap12:operation/>
            <wsdl:input name="getAllCountryRequest">
                <soap12:body use="literal" />
            </wsdl:input>
            <wsdl:output name="getAllCountryResponse">
                <soap12:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="CountriesPortService">
        <wsdl:port name="CountriesPortSoap12" binding="tns:CountriesPortSoap12" >
            <soap12:address location="http://XXX.myexample.local:9090/ws" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
...