Programatically..
serviceClient.addStringHeader(new
javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap12/","AdditionalSoapHeader"),"This
is a sample Header" );
Keep in mind 'header' has a strict definition .. if you want your SOAP header
to pass validation you *should* conform:
<xs:element name="header" type="wsoap12:tHeader"/>
<xs:attributeGroup name="tHeaderAttributes">
<xs:attribute name="message" type="xs:QName" use="required"/>
<xs:attribute name="part" type="xs:NMTOKEN" use="required"/>
<xs:attribute name="use" type="wsoap12:useChoice" use="required"/>
<xs:attribute name="encodingStyle" type="xs:anyURI" use="optional"/>
<xs:attribute name="namespace" type="xs:anyURI" use="optional"/>
</xs:attributeGroup>
<xs:complexType name="tHeader">
<xs:complexContent>
<xs:extension base="wsoap12:tExtensibilityElementOpenAttrs">
<xs:sequence>
<xs:element ref="wsoap12:headerfault" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attributeGroup ref="wsoap12:tHeaderAttributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="headerfault" type="wsoap12:tHeaderFault"/>
<xs:complexType name="tHeaderFault">
<xs:attributeGroup ref="wsoap12:tHeaderAttributes"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<xs:element name="address" type="wsoap12:tAddress"/>
<xs:complexType name="tAddress">
<xs:complexContent>
<xs:extension base="wsoap12:tExtensibilityElementOpenAttrs">
<xs:attribute name="location" type="xs:anyURI" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Be sure to keep conformity with
http://schemas.xmlsoap.org/wsdl/soap12/wsdl11soap12.xsd
otherwise your validating parsers will fail..
Regards,
Martin-
Date: Tue, 31 Dec 2013 01:21:38 +0800
From: [email protected]
Subject: how to include custom soap header definition in wsdl using axis2
framework?
To: [email protected]
we are using axis2 framework and passing security session id as custom soap
header. How to include the soap header definition in wsdl?
Thanks,Venkat
PS: I posted the same question in stack overflow as
well.http://stackoverflow.com/questions/20841310/how-to-include-custom-soap-header-definition-in-wsdl-using-axis2-framework