2014-09-19 5 views
1

웹 서비스를 위에서 아래로 작성했습니다. 먼저 WSDL을 작성한 다음 wsimport 도구를 사용하여 WS 인터페이스와 프록시를 생성했습니다. 마지막으로 WS 구현을 작성했습니다. 이제 WS는 Tomee 1.6 서버에 배포됩니다. WSDL을? wsdl 매개 변수와 함께 호출하면 먼저 작성한 WSDL과 다릅니다. 첫 번째 WSDL에서 서비스 이름은 "ImmoService"인 반면 WSDL에서는 배포 된 웹 서비스를 호출 할 때 "ImmoServiceService"입니다.WSDL은 웹 서비스를 생성하는 데 사용 된 WSDL과 다른 웹 서비스에서 가져온 것임

나는 Tomee의 버그라고 생각했기 때문에 Glassfish에 WS를 배치했습니다. 그러나 나는 같은 결과를 얻었다. 나는 뭔가를 놓친 것 같다. WS에 의해 생성 된 WSDL의 서비스 이름은 WS가 생성 된 WSDL의 서비스 이름과 같지 않아야합니다. 내가 얻을 WSDL 여기

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

는 WSDL 매개 변수 여기

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

와 Tomee에서 내 WS를 호출 할 때 내가 얻을 하나입니다 : 여기에

은 내가 먼저 쓴 WSDL이다 Glassfish에서 내 WS를 호출합니다.

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

답변

2

이것은 Java SOAP Frameworks (Metro, CXF)의 일반적인 동작입니다. 직접 WSDL을 작성하고 wsimport를 사용하여 코드를 생성 한 다음 ?wsdl을 사용하여 생성 된 WSDL을 가져 오는 경우에도 항상 다른 WSDL을 작성합니다. 일부 프레임 워크를 사용하면 서비스를 노출 할 때 자신의 WSDL을 제공 할 수 있습니다 (http://cxf.apache.org/docs/jax-ws-configuration.html 매개 변수 wsdl 위치 참조)

자체 작성된 WSDL이있는 경우 WSDL을 사용하여 클라이언트 및 서비스를 생성 할 수 있습니다. 생성 된 것을 사용하지 마십시오 (그건 내 경험입니다). 생성 된 WSDL은 항상 유효한 끝점을 갖도록 참조 할 수 있지만 더 이상 사용할 수는 없습니다.

+0

나 자신이 작성한 WSDL로 클라이언트를 생성하면이 클라이언트가 작동하지 않습니다. 다음과 같은 오류가 발생합니다 : "WS ImmoService 접근 불가 : {http://ws.csf.fr/ImmoService}ImmoService in wsdl http : // localhost : 8080/ImmoService/webservices/ImmoService? wsdl"서비스를 찾을 수 없습니다. 실제 서비스 이름은 ImmoService (WSDL에서 선택한 서비스)가 아니고 ImmoServiceService (생성 된 WSDL에서 볼 수 있음)이기 때문입니다. 따라서 서버와 클라이언트를 생성하는 데 동일한 WSDL을 사용할 수 없습니다. 나에게 이상한 것 같다. – jmb

+0

@WebService (name = "ImmoServiceSoap", serviceName = "ImmoService", targetNamespace = "http://ws.csf.fr/ImmoService", portName = "ImmoServiceSoap")를 서비스 impl에 추가 해보십시오. 이렇게하면 해결됩니다. – mp911de

+0

그것은 작동합니다. 고마워요! – jmb