We have an external wsdl which we use to make a callout to an external application. The wsdl has a header schema which needs to be passed along with the request. I imported the wsdl and the wsdl2apex class stub has all the request and response classes except the header class. You will notice gwheaders-100 class is included in the stub but it is not added on the request. So the call out fails with header data not found exception. Any idea on how i can pass the header data to the call out please?
Thanks
Buyan
Best Answer
The soap header should be added as a member to the wsdl2apex generated stub class that corresponds to the port. This class will also have the
public String endpoint_c = '...';
member.There should also be a String member generated that ends with
_hns
. This has the namespace mapping for the header.I assume you defined a value for the header member in the stub class?
Alternatively, there is also support for HTTP Headers via the inputHttpHeaders_x Map. See HTTP Header Support:
When I generated the Apex classes from your WSDL the header was called
ServiceName
and had the typegwHeaders100.Service_element
.