2013-10-22 2 views
0

jax-ws 또는 axis와 같은 프레임 워크를 사용하지 않고 웹 서비스를 사용하고자합니다. 이 article을 확인함으로써, 나는 요청을 작성해야합니다.. wsdl을 구문 분석하고 요청 xml 을 동적으로 작성하는 방법이 있습니까?? 나는의 xsd XSInstance하지만 WSDL을

참고와 함께 사용하는 방법을 잘 확인하신 후 : 웹 서비스가 여러 작업을 할 수 있습니다와 나는 몇 가지 매개 변수에 따라 그 중 하나에 대한 요청 XML을 생성 할 필요가xsd에서 웹 서비스 요청 XML을 작성하십시오.

+0

서비스를 정상적으로 배포하고 몇 가지 요청을 보내지 않는 이유는 무엇입니까? Wireshark 또는 sth를 시작하고 요청이 무엇인지 확인하십시오. –

답변

0

일부 프레임 워크는 이유없이 존재하지 않습니다.하지만 단계별로 단계별로 이동하려면 먼저 WSDL 계약에 정의 된 메소드를 살펴보고 메시지 부분에 포함 된 매개 변수를 메소드에 추가해야합니다. 귀하의 링크에서 WSDL 파일이 나

<definitions name="HelloService" 
    targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl" 
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 

    <message name="SayHelloRequest"> 
     <part name="firstName" type="xsd:string"/> 
    </message> 
    <message name="SayHelloResponse"> 
     <part name="greeting" type="xsd:string"/> 
    </message> 

    <portType name="Hello_PortType"> 
     <operation name="sayHello"> 
     <input message="tns:SayHelloRequest"/> 
     <output message="tns:SayHelloResponse"/> 
     </operation> 
    </portType> 

    <binding name="Hello_Binding" type="tns:Hello_PortType"> 
    <soap:binding style="rpc" 
     transport="http://schemas.xmlsoap.org/soap/http"/> 
    <operation name="sayHello"> 
     <soap:operation soapAction="sayHello"/> 
     <input> 
     <soap:body 
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
      namespace="urn:examples:helloservice" 
      use="encoded"/> 
     </input> 
     <output> 
     <soap:body 
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
      namespace="urn:examples:helloservice" 
      use="encoded"/> 
     </output> 
    </operation> 
    </binding> 

    <service name="Hello_Service"> 
     <documentation>WSDL File for HelloService</documentation> 
     <port binding="tns:Hello_Binding" name="Hello_Port"> 
     <soap:address 
      location="http://www.examples.com/SayHello/"> 
     </port> 
    </service> 
</definitions> 
WSDL 파일은 다음과 같은 부분이 포함되어

작동하지 않는 내가 http://www.tutorialspoint.com/wsdl/wsdl_example.htm에서 가져온 예제 WSDL 계약을 사용하십시오 WSDL 계약과 SOAP 메시지 사이의 관계를 보여하려면 서비스를, 바인딩, portType, 작업, 메시지

서비스는 지정된 URL에 바인딩하고 WSDL 계약에 제시된 작업을 제공하는 실제 웹 서비스를 정의합니다. portType은 들어오고 나가는 메시지의 포트를 정의하고 메시지 세그먼트는 수신 및 전송 된 메시지에 대해 예상 할 매개 변수와 반환 값을 정의합니다. http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/

또한, WSDL 파일은 XSD에 대한 링크를 포함 할 수 있습니다 : 여기에 rpc 또는 document 및 수 중 자체 바인딩은 다시 encoded 또는 literal - 자세한 내용 -이 설정은 실제 SOAP의 몸 모양을 어떻게 영향을 미칠 것이다 메시지 매개 변수 또는 반환 유형을 정의하거나 계약 내에서 전체 xsd 정의를 포함합니다.

자바에서 SayHelloRequest의 메소드 선언은 다음과 같이 보일 것이다 : public String sayHello(String firstName);하지만 SOAP 기반의 서비스를 호출하는 것은이 같은 듣기 서비스로 전송하는 XML (SOAP) 메시지가 필요합니다

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/1999/XMLSchema"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <SayHelloRequest> 
      <firstName xsi:type="xsd:string">Test</firstName> 
     </SayHelloRequest> 
    </soapenv:Body> 
</soapenv:Envelope> 

그래서, 프레임 워크없이 WSDL에서 SOAP 메시지를 작성하는 것은 가능하지만 테이블로 가져 오는 오버 헤드를 처리해야한다. 또한 안전 측면에서 xsd를 스스로 검증해야합니다.

이 지식을 사용하면 먼저 서비스 파트를 추출한 다음 고유 한 파서를 작성한 다음 바인딩 및 포트 유형 (정의 된 인코딩 포함)과 마지막으로 중요한 메시지의 수신 및 수신 메시지에 대한 정의 된 작업을 작성할 수 있습니다. 각 작업. 이러한 매개 변수의 유형을 알아 보려면 xsd 유형을 자세히 살펴보고 유사한 Java 클래스를 찾아야합니다.

HTH

+0

덕분에 wsdl의 개념을 이해하는 데 도움이되었습니다. – S4beR