Reputation: 83
I have a wsdl and this wsdl has a request message like this, in SOAPUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:service="www.xxxxx.xx">
<soapenv:Header>
<service:SessionInfo>
<service:UserPassword>?</service:UserPassword>
</service:SessionInfo></soapenv:Header>
<soapenv:Body>
<service:Method1>
<!--Optional:-->
<service:Arguments>
<service:Parameter1>?</service:Parameter1>
<service:Parameter2>?</service:Parameter2>
<!--Optional:-->
<service:Parameter3>?</service:Parameter3>
<!--Optional:-->
<service:Parameter4>?</service:Parameter4>
</service:Arguments>
</service:Method1></soapenv:Body></soapenv:Envelope>
I am having problem while sending header message of this wsdl in Java. I sent the request message in C# and SOAPUI successfully. After importing wsdl in Java I could not access the header part of this request although I was able to access in SOAPUI and C#. I can only access body part of this wsdl in Java but I cannot access soapenv:Header part in Java. Is there a solution for this problem by using org.apache.axis.client.Stub and java.rmi.Remote? How can I add header? Thanks.
Upvotes: 2
Views: 1290
Reputation: 1
With org.apache.axis.axis
library, just cast the service port to org.apache.axis.client.Stub
to add a specific header :
// Instanciate the service
ExampleServices Service service = new ExampleServicesServiceLocator();
ExampleServices port = service.getExampleServicesServicePort();
// Cast the port to Stub
Stub stub = (Stub)port;
// Set header
stub.setHeader(/* SOAPHeaderElement header */);
Upvotes: 0
Reputation: 11
you can add custom headers
as below:
MessageContext responseMessageContext =
MessageContext.getCurrentMessageContext().getOperationContext().getMessageContext(
WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
List headers = new ArrayList();
headers.add(new Header(HTTPConstants.HEADER_CONTENT_ENCODING, "identity"));
responseMessageContext.setProperty(HTTPConstants.HTTP_HEADERS, headers);
or else check this way from the link here
Upvotes: 1