2017-03-20 1 views
0

SOAP 요청을 구성 할 때 문제가 있습니다.Soap Request Java에서 헤더를 설정하는 방법

그 요청에서 페이로드 부분이 아닌 헤더 부분에 사용자 이름, 암호 및 기타 정보를 추가해야합니다. WSDL

<wsdl:message name="InputUploadCustomerDocument_Headers"> 
<wsdl:part name="DocumentType" element="tns:DocumentType"/> 
<wsdl:part name="FileName" element="tns:FileName"/> 
<wsdl:part name="Password" element="tns:Password"/> 
<wsdl:part name="PinNo" element="tns:PinNo"/> 
<wsdl:part name="UserName" element="tns:UserName"/> 
</wsdl:message> 
<wsdl:message name="ReturnUploadCustomerDocument"> 
<wsdl:part name="parameters" element="tns:ReturnUploadCustomerDocument"/> 
</wsdl:message> 


<wsdl:operation name="UploadCustomerDocument"> 
<soap:operation soapAction="http://tempuri.org/ISend/UploadCustomerDocument" style="document"/> 
<wsdl:input name="InputUploadCustomerDocument"> 
<soap:header message="tns:InputUploadCustomerDocument_Headers" part="DocumentType" use="literal"/> 
<soap:header message="tns:InputUploadCustomerDocument_Headers" part="FileName" use="literal"/> 
<soap:header message="tns:InputUploadCustomerDocument_Headers" part="Password" use="literal"/> 
<soap:header message="tns:InputUploadCustomerDocument_Headers" part="PinNo" use="literal"/> 
<soap:header message="tns:InputUploadCustomerDocument_Headers" part="UserName" use="literal"/> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output name="ReturnUploadCustomerDocument"> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 

의 항목 아래 InputUploadCustomerDocument 자바 파일 아래

이 파일은 사용자 이름, 암호 및 기타 분야가 없습니다, 그리고 난 reuqest

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "", propOrder = { 
"fileData" 
}) 
@XmlRootElement(name = "InputUploadCustomerDocument") 
public class InputUploadCustomerDocument { 

@XmlElement(name = "FileData", required = true) 
protected byte[] fileData; 

/** 
* Gets the value of the fileData property. 
* 
* @return 
*  possible object is 
*  byte[] 
*/ 
public byte[] getFileData() { 
    return fileData; 
} 

/** 
* Sets the value of the fileData property. 
* 
* @param value 
*  allowed object is 
*  byte[] 
*/ 
public void setFileData(byte[] value) { 
    this.fileData = value; 
} 
을하기 전에이 매개 변수를 설정해야합니다

} 여기

제가

0을 호출해야하는 함수

이 헤더를 어떻게 설정할 수 있습니까?

답변

1

당신은 당신이 JAX-WS를 사용하고 있기 때문에, 요청을하기 전에 헤더를 추가 라인 아래에이를 사용할 수 있습니다

SOAPHeader header = envelope.addHeader(); 

당신이 참조 할 수 자습서의 많음이있다. google로 이동하여 SOAP 웹 서비스를 검색하십시오. 여기

http://www.javadb.com/using-a-message-handler-to-alter-the-soap-header-in-a-web-service-client/

당신이 사용할 수있는 또 다른 좋은 예는 다음과 같습니다 :이 도움이 https://soa2world.blogspot.com/2009/05/direct-web-service-client-using-java.html

희망 여기를 참조 할 수 있습니다 하나의 튜토리얼입니다.

관련 문제