2010-07-29 4 views
0

SOAP 1.2 메시지를받는 서버를 작성하고 있습니다. 내가 가진 문제는 SOAP 1.1 메시지를 SOAPUI를 통해 전송할 때 메시지가 올바르게 처리되지만 SOAP 1.2 메시지가 아닌 경우입니다. 나는 axis2를 사용한다. SOAP 1.2에서 Axis 2가 파싱되지 않았습니다.

<dependencies> 
    <dependency> 
     <groupId>org.apache.axis2</groupId> 
     <artifactId>axis2-saaj</artifactId> 
     <version>1.4.1</version> 
    </dependency> 
    </dependencies> 

가 여기에 서버를 실행하는 내 주요 루틴 :

여기 내 POM 의존성이다. 이것은 실제 서버 (스레드 없음)가 아니며, 그 목적은 문제를 보여주는 것입니다.

public class App { 
    public static void main(String[] args) { 
     try { 
      ServerSocket server = new ServerSocket(3400); 
      Socket socket = server.accept(); 
      BasicHttpParams params = new BasicHttpParams(); 
      DefaultHttpServerConnection conn = new DefaultHttpServerConnection(); 
      conn.bind(socket, params); 
      HttpRequest request = conn.receiveRequestHeader(); 
      if (request instanceof HttpEntityEnclosingRequest) { 
       conn.receiveRequestEntity((HttpEntityEnclosingRequest) request); 
       HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); 
       if (entity != null) { 
        MessageFactory soapMessageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); 
        SOAPMessage soapMessage = soapMessageFactory.createMessage(
          new MimeHeaders(), entity.getContent()); 
        SOAPBody soapBody = soapMessage.getSOAPBody(); 
        entity.consumeContent(); 
       } 
      } 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 

SOAP 1.1 메시지

<?xml version='1.0' encoding='utf-8'?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Header/> 
    <soapenv:Body> 
    </soapenv:Body> 
</soapenv:Envelope> 

SOAP 1.2 메시지

<?xml version='1.0' encoding='utf-8'?> 
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Body> 
    </soapenv:Body> 
</soapenv:Envelope> 

내가

javax.xml.soap.SOAPException: org.apache.axiom.soap.SOAPProcessingException: Disallowed element found inside Envelope : {http://www.w3.org/2003/05/soap-envelope}Body 
    at org.apache.axis2.saaj.SOAPPartImpl.<init>(SOAPPartImpl.java:228) 
    at org.apache.axis2.saaj.SOAPPartImpl.<init>(SOAPPartImpl.java:246) 
    at org.apache.axis2.saaj.SOAPMessageImpl.<init>(SOAPMessageImpl.java:99) 
    at org.apache.axis2.saaj.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:131) 
    at lolissimo.xhiara.App.main(App.java:33) 

답변

1

당신은 공식 구현을 시도해야 1.2 메시지와 함께있어 예외 SAAJ.

<dependency> 
    <groupId>com.sun.xml.messaging.saaj</groupId> 
    <artifactId>saaj-impl</artifactId> 
    <version>1.3.4</version> 
    <type>jar</type> 
    <scope>compile</scope> 
</dependency> 
1

스프링 프레임 워크 WS에 액세스 할 때 동일한 오류가 발생했습니다.

출력 XML을 사용자 정의하기위한 몇 가지 의도와 수정을 마침내 "http://schemas.xmlsoap.org/soap/envelope/" 대신이 uri가 "http://www.w3.org/2003/05/soap-envelope"이되었습니다. 대신

MessageFactory.newInstance(); 

: 당신은 여전히 ​​당신의 접두사와 네임 스페이스를 사용자 정의 할 수 있습니다 두 경우 모두

MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); 

그래서, 1.2 1.1에서 프로토콜 사양을 chanching하는 것은 문제를 해결했다. 그리고 봄철 WS를 먹으려 고한다면 봉투에 "soapenv"이라는 접두사를 포함해야합니다.

1

WSDL 끝점이있는 기존 웹 서비스에 연결하는 동안 WSWS4104E: A SOAP 1.2 Protocol is not supported by SAAJ 1.2. 오류가 발생했습니다. IBM 특정 jar이 클래스 경로에없는 것으로 확인되었습니다. jar 파일은 com.ibm.jaxws.thinclient_8.0.0.jar입니다.

변수 이름은 WAS_V8JAXWS_WEBSERVICES_THINCLIENT입니다. 이 변수를 Java Build Path에 추가 한 후에는 더 이상이 오류를 볼 수 없습니다.

또한 다른 버전에 대한 링크 : http://www-01.ibm.com/support/docview.wss?uid=swg21316678

관련 문제