简体   繁体   中英

WSDL got from a web service different from WSDL used to produce the web service

I have written a web service in a top down way : I wrote de WSDL first, then I used the wsimport tool to produce the WS interface and the proxies, and finally I wrote the WS implementation. Now, my WS is deployed on a Tomee 1.6 server, and when I invoke it with a ?wsdl parameter, I get a WSDL wich is different from the one I wrote first. In my first WSDL the service name was "ImmoService", whereas in the WSDL I get when invoking the deployed web service, it is "ImmoServiceService".

I first thought it was a bug in Tomee, so I deployed the WS on Glassfish. But I got the same result. It seems that I have missed something. The name of the service in the WSDL produced by the WS should not be the same as the name of the service in the WSDL from which the WS was produced ?

Here is the WSDL I wrote first :

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
         xmlns:s="http://www.w3.org/2001/XMLSchema" 
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
         xmlns:rp="http://ws.csf.fr/ImmoService"
         targetNamespace="http://ws.csf.fr/ImmoService">
<types>
    ...
</types>

<!-- =========================================================================
                                     Messages
     ========================================================================= -->
<message name="imprimerDocumentsSoapIn">
    <part name="parameters" element="rp:imprimerDocuments"/>
</message>
<message name="imprimerDocumentsSoapOut">
    <part name="parameters" element="rp:imprimerDocumentsResponse"/>
</message>

<!-- =========================================================================
                                      PortType
     ========================================================================= -->

<portType name="ImmoServiceSoap">
    <operation name="imprimerDocuments">
        <input message="rp:imprimerDocumentsSoapIn"/>
        <output message="rp:imprimerDocumentsSoapOut"/>
    </operation>
</portType>

<!-- =========================================================================   
                                      Binding
     ========================================================================= -->
<binding name="ImmoServiceSoap" type="rp:ImmoServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="imprimerDocuments">
        ...
    </operation>
</binding>

<!-- =========================================================================   
                                    Service
     ========================================================================= -->
<service name="ImmoService">
    <port name="ImmoServiceSoap" binding="rp:ImmoServiceSoap">
        <soap:address location="http://serveur:0/ImmoService/webservices/ImmoService"/>
    </port>
</service>

</definitions>

Here is the one I get when invoking my WS under Tomee with the ?wsdl parameter

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.immoservice.csf.fr/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:ns1="http://ws.csf.fr/ImmoService" name="ImmoServiceService" targetNamespace="http://ws.immoservice.csf.fr/">
    <wsdl:import location="http://vir-ws-int.csf.asso.fr:8080/ImmoService/webservices/ImmoService?wsdl=ImmoServiceSoap.wsdl" namespace="http://ws.csf.fr/ImmoService">
    </wsdl:import>
    <wsdl:binding name="ImmoServiceServiceSoapBinding" type="ns1:ImmoServiceSoap">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="imprimerDocuments">
            <soap:operation soapAction="http://csf.fr/ImmoService/imprimerDocuments" style="document"/>
            <wsdl:input name="imprimerDocuments">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="imprimerDocumentsResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="ImmoServiceService">
        <wsdl:port binding="tns:ImmoServiceServiceSoapBinding" name="ImmoServicePort">
            <soap:address location="http://vir-ws-int.csf.asso.fr:8080/ImmoService/webservices/ImmoService"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

Here is the WSDL I get when I invoke my WS under Glassfish :

<?xml version='1.0' encoding='UTF-8'?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.3 (tags/2.3-7528; 2013-04-29T19:34:10+0000) JAXWS-RI/2.2.8 JAXWS/2.2 svn-revision#unknown. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.3 (tags/2.3-7528; 2013-04-29T19:34:10+0000) JAXWS-RI/2.2.8 JAXWS/2.2 svn-revision#unknown. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.immoservice.csf.fr/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.immoservice.csf.fr/" name="ImmoServiceService">
    <import namespace="http://ws.csf.fr/ImmoService" location="http://localhost:8081/ImmoServiceService/ImmoService?wsdl=1"/>
    <binding xmlns:ns1="http://ws.csf.fr/ImmoService" name="ImmoServicePortBinding" type="ns1:ImmoServiceSoap">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <operation name="imprimerDocuments">
            <soap:operation soapAction="http://csf.fr/ImmoService/imprimerDocuments"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>
    <service name="ImmoServiceService">
        <port name="ImmoServicePort" binding="tns:ImmoServicePortBinding">
            <soap:address location="http://localhost:8081/ImmoServiceService/ImmoService"/>
        </port>
    </service>
</definitions>

This is the normal behavior of Java SOAP Frameworks (Metro, CXF). They always create a different WSDL even if you wrote a WSDL by hand, generated Code using wsimport and then fetch the generated WSDL using ?wsdl . Some frameworks allow you to provide your own WSDL when exposing the Service (see http://cxf.apache.org/docs/jax-ws-configuration.html Param wsdlLocation)

If you have a self-written WSDL, use it to generate Clients and Services using your WSDL. Do not use the generated one (That's my experience). You can reference the generated WSDL for having an always valid Endpoint but not for more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM