Adding a Custom header to your Web Service (WSDL)
- 08
- December
- 2010
- By admin
- BPM, Design Patterns, ESB, Java, OESB, OSB, SOA, SOAP, Web Services
- 2 Comments.
It’s very common that you have to define a WSDL and want it to have custom header.
I have been using WSDL’s with custom headers for some time and thought I will post this sample WSDL for all of you who want to define a SOAP 1.1 WSDL with a custom message header.
Below is a Sample SOAP 1.1 WSDL with custom headers.
LocationFinderService.wsdl
<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?>
<wsdl:definitions xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/”
xmlns:tns=”http://www.nysolutionsltd.com/wsdl/utilityservices/addressfinderservice/LocationFinderServicev1.0/”
xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
name=”LocationFinderService”
xmlns:header=”http://www.nysolutionsltd.com/wsdlheaders/Headerv1.0″
targetNamespace=”http://www.nysolutionsltd.com/wsdl/utilityservices/addressfinderservice/LocationFinderServicev1.0/”
xmlns:xsd1=”http://www.nysolutionsltd.com/wsdlmessages/utilityservices/addressfinderservice/FindGeocodesForLocationv1.0″>
<wsdl:types>
<xsd:schema
targetNamespace=”http://www.nysolutionsltd.com/wsdl/utilityservices/addressfinderservice/LocationFinderServicev1.0/”>
</xsd:schema>
<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<xsd:import
namespace=”http://www.nysolutionsltd.com/wsdlmessages/utilityservices/addressfinderservice/FindGeocodesForLocationv1.0″
schemaLocation=”../../../../../ServiceSchemas/internal/wsdlmessages/utilityservices/addressfinderservice/FindGeocodesForLocation.xsd”>
</xsd:import>
<xsd:import
schemaLocation=”../../../../../ServiceSchemas/internal/wsdlheaders/HeaderSchema.xsd”
namespace=”http://www.nysolutionsltd.com/wsdlheaders/Headerv1.0″ />
</xsd:schema>
</wsdl:types>
<wsdl:message name=”MessageHeaderType”>
<wsdl:documentation>
The Messages used in the operations of this service are
defined here. The element attribute refers to the various
types defined in the schema.
</wsdl:documentation>
<wsdl:part name=”MessageHeaderType”
element=”header:MessageHeaderType” />
</wsdl:message>
<wsdl:message name=”findGeocodesForLocationRequest”>
<wsdl:part element=”xsd1:findGeocodesForLocationRequest”
name=”parameters” />
</wsdl:message>
<wsdl:message name=”findGeocodesForLocationResponse”>
<wsdl:part element=”xsd1:findGeocodesForLocationResponse”
name=”parameters” />
</wsdl:message>
<wsdl:portType name=”LocationFinderService”>
<wsdl:operation name=”findGeocodesForLocation”>
<wsdl:input message=”tns:findGeocodesForLocationRequest” />
<wsdl:output message=”tns:findGeocodesForLocationResponse” />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name=”LocationFinderServiceSOAP”
type=”tns:LocationFinderService”>
<soap:binding style=”document”
transport=”http://schemas.xmlsoap.org/soap/http” />
<wsdl:operation name=”findGeocodesForLocation”>
<soap:operation
soapAction=”http://www.nysolutionsltd.com/wsdl/utilityservices/addressfinderservice/LocationFinderServicev1.0/findGeocodesForLocation” />
<wsdl:input>
<soap:header message=”tns:MessageHeaderType”
part=”MessageHeaderType” use=”literal” />
<soap:body use=”literal” />
</wsdl:input>
<wsdl:output>
<soap:body use=”literal” />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name=”LocationFinderService”>
<wsdl:port binding=”tns:LocationFinderServiceSOAP”
name=”LocationFinderServiceSOAP”>
<soap:address location=”http://www.nysolutionsltd.com/” />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
For Custom headers
Things to note are to define the custom header type:
<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<xsd:import
namespace=”http://www.nysolutionsltd.com/wsdlmessages/utilityservices/addressfinderservice/FindGeocodesForLocationv1.0″
schemaLocation=”../../../../../ServiceSchemas/internal/wsdlmessages/utilityservices/addressfinderservice/FindGeocodesForLocation.xsd”>
</xsd:import>
<xsd:import
schemaLocation=”../../../../../ServiceSchemas/internal/wsdlheaders/HeaderSchema.xsd”
namespace=”http://www.nysolutionsltd.com/wsdlheaders/Headerv1.0″ />
</xsd:schema>
</wsdl:types>
<wsdl:message name=”MessageHeaderType”>
<wsdl:documentation>
The Messages used in the operations of this service are
defined here. The element attribute refers to the various
types defined in the schema.
</wsdl:documentation>
<wsdl:part name=”MessageHeaderType”
element=”header:MessageHeaderType” />
</wsdl:message>
And to include that in the input message:
<wsdl:input>
<soap:header message=”tns:MessageHeaderType”
part=”MessageHeaderType” use=”literal” />
<soap:body use=”literal” />
</wsdl:input>
For Soap 1.1 the namespace have to be
xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/
NOTE: this can be used with SOAP1.2 as well but you just need to update the WSDL bindings etc.
I will try and post a SOAP1.2 WSDL as well. But that’s for another day.
I use the O2 Broadband service its dirt cheap and service is so very good I would recommend the it to one and all.
Related
2 Responses so far.
Recent Posts
- 12.1.0.2 RAC Installation – Step by Step installation on VMware
- OSB FTP Poller continuously throwing exception – while no file pending on FTP Location
- Using JMS Transport with OSB
- Installing Spring Tool Suite and configuring Spring for a development PC
- Rest Enabling SOA using OSB in Oracle 12c
Recent Comments
- Nits on Installing Oracle SOA Suite 12c
- Rajesh Krishna on Installing Oracle SOA Suite 12c
- Nits on Installing Oracle SOA Suite 12c
- Rohinii on Installing Oracle SOA Suite 12c
- Mahitha on Oracle Service Bus (OSB) Development Best Practices.
Archives
- December 2015
- May 2015
- November 2014
- September 2014
- August 2014
- July 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- July 2013
- June 2013
- May 2013
- March 2013
- February 2013
- November 2012
- October 2012
- September 2012
- May 2012
- March 2012
- February 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- June 2011
- May 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- July 2010
- June 2010
- March 2010
- February 2010
- December 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- August 2008
- June 2008
- May 2008
Categories
- AIA
- AXIS2
- Best Practices
- BPEL
- BPM
- Budget
- Build
- Design Patterns
- ESB
- Hermes
- Hibernate
- Home Owners
- Java
- JMS
- JSR 168
- Maven
- Mediator
- Messaging
- Nitin
- OER
- OESB
- Oracle
- OSB
- OWSM
- Portlets
- SDLC
- Sequencing
- Singleton
- SOA
- SOAP
- Spring
- Struts
- UK
- Uncategorized
- Web Services
- WLST
Meta
To find out more, including how to control cookies, see here: Cookie Policy
Recent Posts
- 12.1.0.2 RAC Installation – Step by Step installation on VMware
- OSB FTP Poller continuously throwing exception – while no file pending on FTP Location
- Using JMS Transport with OSB
- Installing Spring Tool Suite and configuring Spring for a development PC
- Rest Enabling SOA using OSB in Oracle 12c
Recent Comments
- Nits on Installing Oracle SOA Suite 12c
- Rajesh Krishna on Installing Oracle SOA Suite 12c
- Nits on Installing Oracle SOA Suite 12c
- Rohinii on Installing Oracle SOA Suite 12c
- Mahitha on Oracle Service Bus (OSB) Development Best Practices.
Archives
- December 2015
- May 2015
- November 2014
- September 2014
- August 2014
- July 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- July 2013
- June 2013
- May 2013
- March 2013
- February 2013
- November 2012
- October 2012
- September 2012
- May 2012
- March 2012
- February 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- June 2011
- May 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- July 2010
- June 2010
- March 2010
- February 2010
- December 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- August 2008
- June 2008
- May 2008
Categories
- AIA
- AXIS2
- Best Practices
- BPEL
- BPM
- Budget
- Build
- Design Patterns
- ESB
- Hermes
- Hibernate
- Home Owners
- Java
- JMS
- JSR 168
- Maven
- Mediator
- Messaging
- Nitin
- OER
- OESB
- Oracle
- OSB
- OWSM
- Portlets
- SDLC
- Sequencing
- Singleton
- SOA
- SOAP
- Spring
- Struts
- UK
- Uncategorized
- Web Services
- WLST
hi
can you also post the headerschema xsd. I want to add a custom header to my wsdl. Also do you have any idea on WS-addressing . How to implement it in existing wsdl.
Looks like you are an expert in this field, you got some great points there, but you’ll want to add a facebook button to your blog. I just bookmarked this article, although I had to complete it manually. Simply my $.02 🙂
– Daniel