2014-09-17 7 views
0

나는 외부 시스템에 로그인이 코드를 사용하고 있습니다 :비누 머리글 정보에 액세스하는 방법?

LoginResponse response = (LoginResponse) webServiceTemplate.marshalSendAndReceive(myRequest, new WebServiceMessageCallback() { 

     public void doWithMessage(WebServiceMessage message) { 
        ((SoapMessage)message).setSoapAction("http://www.system.com//Authentication/Login"); 
      } 
     }); 

나는 LoginResponse의 유형을받을 수 있지만, 아무 값이다. 내가 헤더에서 UserAuth 값에 접근 필요

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "") 
@XmlRootElement(name = "LoginResponse", namespace = "http://www.system.com/Authentication/") 
public class LoginResponse { 


} 

그러나 이것은 LoginResponse 객체에 포함되지 않습니다

LoginResponse 유형은 포함되어 있습니다.

SOAP 응답은 다음과 같습니다

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Header> 
     <UserAuth xmlns="http://www.system.com/ws/"> 
     <Value>234234k234jl2k</Value> 
     </UserAuth> 
    </soap:Header> 
    <soap:Body> 
     <LoginResponse xmlns="http://www.system.com/Authentication"/> 
    </soap:Body> 
</soap:Envelope> 

가 어떻게이 경우, UserAuth 값을 헤더 정보를 액세스 할 수 있습니까?

낮은 수준에서 무언가를 사용해야하고 비누 반응에서 필요한 값을 분석해야합니까?

업데이트 :

내가 SAAJ를 사용하여 사용자 정의 SOAP 요청 (SOAP request to WebService with java 유사한)를 사용하고 응답을 처리해야합니다 생각합니다.

내 이해는 응답 내의 SOAP 헤더가 선택 사항이지만 대부분의 클라이언트는 SOAP을 사용할 때 헤더를 사용하여 인증 유형 정보를 보냅니다. 아마도 wsdl 또는 .class 파일을 생성하는 메커니즘이 잘못되어 응답이 필요한 모든 필드 (이 경우 비누 헤더)를 채우지 못하는 것일 수 있습니다.

답변

1

로그인 작업에 대한 응답으로받은 UserAuth 헤더의 정보는 서비스에 대한 후속 요청에서 SOAP 헤더 (잠재적으로 수신 된 헤더와 동일)로 전송되어야한다고 가정합니다. 그렇다면 사용자 정의 ClientInterceptor을 작성하여 WebServiceTemplate에 등록해야합니다. 이 인터셉터는 로그인 응답에서 헤더를 추출하고 필요에 따라 변환 한 후 후속 요청에 추가합니다.

이 인터셉터는 상태 저장에주의하십시오. 따라서 각 대화마다 별도의 WebServiceTemplate 인스턴스를 사용해야합니다.