2016-06-04 2 views
0
내가 예를 들어 puroposes, SpringWS에 노출 된 비누 WS에 대한 호출하려고 사투를 벌인거야

: 여기가 내 WSDL은 바람둥이에 배포봄 SOAP WS 클라이언트

..

<!--Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.3-b01-.--> 
<!--Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.3-b01-.--> 
<definitions targetNamespace="http://ws.mkyong.com/" name="HelloWorldWSService" 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.mkyong.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"> 
    <types> 
     <xsd:schema> 
     <xsd:import namespace="http://ws.mkyong.com/" schemaLocation="http://localhost:8080/web_services/hello?xsd=1"/> 
     </xsd:schema> 
    </types> 
    <message name="findById"> 
     <part name="parameters" element="tns:findById"/> 
    </message> 
    <message name="findByIdResponse"> 
     <part name="parameters" element="tns:findByIdResponse"/> 
    </message> 
    <message name="saveJob"> 
     <part name="parameters" element="tns:saveJob"/> 
    </message> 
    <message name="saveJobResponse"> 
     <part name="parameters" element="tns:saveJobResponse"/> 
    </message> 
    <message name="findJobByName"> 
     <part name="parameters" element="tns:findJobByName"/> 
    </message> 
    <message name="findJobByNameResponse"> 
     <part name="parameters" element="tns:findJobByNameResponse"/> 
    </message> 
    <message name="findJobByRole"> 
     <part name="parameters" element="tns:findJobByRole"/> 
    </message> 
    <message name="findJobByRoleResponse"> 
     <part name="parameters" element="tns:findJobByRoleResponse"/> 
    </message> 
    <message name="deleteJob"> 
     <part name="parameters" element="tns:deleteJob"/> 
    </message> 
    <message name="deleteJobResponse"> 
     <part name="parameters" element="tns:deleteJobResponse"/> 
    </message> 
    <message name="getAllJobs"> 
     <part name="parameters" element="tns:getAllJobs"/> 
    </message> 
    <message name="getAllJobsResponse"> 
     <part name="parameters" element="tns:getAllJobsResponse"/> 
    </message> 
    <message name="updateJob"> 
     <part name="parameters" element="tns:updateJob"/> 
    </message> 
    <message name="updateJobResponse"> 
     <part name="parameters" element="tns:updateJobResponse"/> 
    </message> 
    <portType name="HelloWorldWS"> 
     <operation name="findById"> 
     <input wsam:Action="http://ws.mkyong.com/HelloWorldWS/findByIdRequest" message="tns:findById"/> 
     <output wsam:Action="http://ws.mkyong.com/HelloWorldWS/findByIdResponse" message="tns:findByIdResponse"/> 
     </operation> 
     <operation name="saveJob"> 
     <input wsam:Action="http://ws.mkyong.com/HelloWorldWS/saveJobRequest" message="tns:saveJob"/> 
     <output wsam:Action="http://ws.mkyong.com/HelloWorldWS/saveJobResponse" message="tns:saveJobResponse"/> 
     </operation> 
     <operation name="findJobByName"> 
     <input wsam:Action="http://ws.mkyong.com/HelloWorldWS/findJobByNameRequest" message="tns:findJobByName"/> 
     <output wsam:Action="http://ws.mkyong.com/HelloWorldWS/findJobByNameResponse" message="tns:findJobByNameResponse"/> 
     </operation> 
     <operation name="findJobByRole"> 
     <input wsam:Action="http://ws.mkyong.com/HelloWorldWS/findJobByRoleRequest" message="tns:findJobByRole"/> 
     <output wsam:Action="http://ws.mkyong.com/HelloWorldWS/findJobByRoleResponse" message="tns:findJobByRoleResponse"/> 
     </operation> 
     <operation name="deleteJob"> 
     <input wsam:Action="http://ws.mkyong.com/HelloWorldWS/deleteJobRequest" message="tns:deleteJob"/> 
     <output wsam:Action="http://ws.mkyong.com/HelloWorldWS/deleteJobResponse" message="tns:deleteJobResponse"/> 
     </operation> 
     <operation name="getAllJobs"> 
     <input wsam:Action="http://ws.mkyong.com/HelloWorldWS/getAllJobsRequest" message="tns:getAllJobs"/> 
     <output wsam:Action="http://ws.mkyong.com/HelloWorldWS/getAllJobsResponse" message="tns:getAllJobsResponse"/> 
     </operation> 
     <operation name="updateJob"> 
     <input wsam:Action="http://ws.mkyong.com/HelloWorldWS/updateJobRequest" message="tns:updateJob"/> 
     <output wsam:Action="http://ws.mkyong.com/HelloWorldWS/updateJobResponse" message="tns:updateJobResponse"/> 
     </operation> 
    </portType> 
    <binding name="HelloWorldWSPortBinding" type="tns:HelloWorldWS"> 
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> 
     <operation name="findById"> 
     <soap:operation soapAction=""/> 
     <input> 
      <soap:body use="literal"/> 
     </input> 
     <output> 
      <soap:body use="literal"/> 
     </output> 
     </operation> 
     <operation name="saveJob"> 
     <soap:operation soapAction=""/> 
     <input> 
      <soap:body use="literal"/> 
     </input> 
     <output> 
      <soap:body use="literal"/> 
     </output> 
     </operation> 
     <operation name="findJobByName"> 
     <soap:operation soapAction=""/> 
     <input> 
      <soap:body use="literal"/> 
     </input> 
     <output> 
      <soap:body use="literal"/> 
     </output> 
     </operation> 
     <operation name="findJobByRole"> 
     <soap:operation soapAction=""/> 
     <input> 
      <soap:body use="literal"/> 
     </input> 
     <output> 
      <soap:body use="literal"/> 
     </output> 
     </operation> 
     <operation name="deleteJob"> 
     <soap:operation soapAction=""/> 
     <input> 
      <soap:body use="literal"/> 
     </input> 
     <output> 
      <soap:body use="literal"/> 
     </output> 
     </operation> 
     <operation name="getAllJobs"> 
     <soap:operation soapAction=""/> 
     <input> 
      <soap:body use="literal"/> 
     </input> 
     <output> 
      <soap:body use="literal"/> 
     </output> 
     </operation> 
     <operation name="updateJob"> 
     <soap:operation soapAction=""/> 
     <input> 
      <soap:body use="literal"/> 
     </input> 
     <output> 
      <soap:body use="literal"/> 
     </output> 
     </operation> 
    </binding> 
    <service name="HelloWorldWSService"> 
     <port name="HelloWorldWSPort" binding="tns:HelloWorldWSPortBinding"> 
     <soap:address location="http://localhost:8080/web_services/hello"/> 
     </port> 
    </service> 
</definitions> 

내가 좋아하는 것 주요 메소드를 SpringWS로 호출하면 테스트 할 간단한 클라이언트를 정의 할 수있다. SpringWS를 사용하면 몇 가지 제안이나 링크를 제공하면 좋을 것이다. 요청 매개 변수로 Object를 보내는 방법에 대한 예제와 WS 메소드에 매개 변수가없는 경우 빈 입력 요청을 보냅니다.

언급이 링크 또는 코드 내가 너무 많은 다른 사례를 발견 큰 도움이 될 것입니다, 아무도 내가 함께 갈 제안

답변

-1

지금은 조금 혼란스러워지고 내 요구 및 메신저 .. 맞는 없다 봄 WebServiceTemplate

WebServiceTemplate - WebServiceTemplate 봄-WS에서 클라이언트 측 웹 서비스 액세스를위한 핵심 클래스입니다. Source 객체를 보내고 응답 메시지를 Source 또는 Result로 수신하는 메소드를 포함합니다. 또한 객체를 XML로 마샬링하여 전송을 통해 객체를 전송 한 다음 응답 XML을 객체로 다시 비 정렬화할 수 있습니다.

단계 1 :

1. Copy you are WSDL file into local directory 
    2. Open Command Promote 
    3. wsimport -p mypackage -keep -verbose myservice.wsdl 

This command generated object request and response 

단계 2 : Marshaller의 구성

비누 메시지 공장

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"> 
    <property name="soapVersion"> 
     <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12" /> 
    </property> 
    </bean> 

3 단계 ApplicationContext.xml 구성

샘플 예 WSDL하여 객체를 생성 할

<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> 
    <property name="contextPaths" value="package"/> 
    </bean> 

4 단계 : WebServiceTemplate 구성 5

<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"> 
    <constructor-arg ref="messageFactory" /> 
    <property name="marshaller" ref="marshaller"></property> 
    <property name="unmarshaller" ref="marshaller"></property>    
    <property name="defaultUri" value="wsdlLocation" /> 
    </bean> 

단계 :

가 연결 클라이언트를 준비합니다

import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.ws.client.core.WebServiceTemplate; 

class ClientConnection { 

    @Autowired 
    private WebServiceTemplate webServiceTemplate; 

    public synchronized Object sendRequestAndReceive(Object xmlRequest, 
      final String uri) { 
     webServiceTemplate.setDefaultUri(uri); 
     Object object = webServiceTemplate.marshalSendAndReceive(xmlRequest); 
     return object; 
    } 
} 

자세한 내용은, 아래 링크를 참조하시기 바랍니다.

Spring WS Template example

관련 문제