2

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

4
3

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:

docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.inputHttpHeaders_x = new Map<String, String>();

//Setting a custom HTTP header
stub.inputHttpHeaders_x.put('myHeader', 'myValue');

When I generated the Apex classes from your WSDL the header was called ServiceName and had the type gwHeaders100.Service_element.

public class ingdirectComWsdlLoanCreateleadWsdl {
    public class loan_CreateLead_HTTPPort {
        public String endpoint_x = 'http://localhost:8080/wesp-dgw/';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        // ... snip ...
        public gwHeaders100.Service_element ServiceName; // <---- This is the input soap:header
        private String ServiceName_hns = 'Service=urn:gw-headers-100';
        private String[] ns_map_type_info = new String[]{'urn:gw-headers-100', 'gwHeaders100', 'urn:gw-message-100', 'gwMessage100', 'urn:gw-message-200', 'gwMessage200', 'http://ingdirect.com/wsdl/loan_CreateLead.wsdl', 'ingdirectComWsdlLoanCreateleadWsdl', 'urn:gw-ingdirect-services-lendingservices-contracts-common-100', 'gwIngdirectServicesLendingservicesCo', 'urn:gw-loanserviceenvelope-100', 'gwLoanserviceenvelope100'};
        // ... snip ...
    }
}
2
  • Thanks for your reply.Do you know why wsd2apex ignore soap header and does not generate it on the stub class? Do you have any sample wsdl or apex class where you handcoded the soap header information please? Let me know.. Oct 23 '13 at 10:33
  • @buyankumar When I tried generating the classes the soap input header showed up as ServiceName. Is this the one you were after? Oct 23 '13 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.