title: Create WSO2 Proxy based on WSDL with mandatory header
body: <p>In my scenario a have a webservice "SolverDummyWS" running in WSO2-AS, and want to generate a Proxy for this Service inside WSO2 ESB.</p>
  
  <p>Therefore I created a wsdl for the proxy manually, and added some mandatory header fields. So only the wsdl of the proxy should have this headers. The headers should all be mandatory and defined als EXPLICIT HEADERS.</p>
  
  <p>Proxy-WSDL looks like this:</p>
  
  <pre><code>&lt;wsdl:definitions name="SolverDummyProxy"
  targetNamespace="http://de.unistuttgart.iaas" xmlns:tns="http://de.unistuttgart.iaas"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"&gt;
  
  &lt;wsdl:types&gt;
      &lt;schema targetNamespace="http://de.unistuttgart.iaas"
          xmlns="http://www.w3.org/2001/XMLSchema"&gt;
          &lt;element name="createGrid"&gt;
              &lt;complexType&gt;
                  &lt;sequence&gt;
                      &lt;element minOccurs="0" name="milliseconds" type="long" /&gt;
                  &lt;/sequence&gt;
              &lt;/complexType&gt;
          &lt;/element&gt;
          &lt;element name="createGridResponse"&gt;
              &lt;complexType&gt;
                  &lt;sequence&gt;
                      &lt;element minOccurs="0" name="return" type="string" /&gt;
                  &lt;/sequence&gt;
              &lt;/complexType&gt;
          &lt;/element&gt;
          &lt;element name="requestHeader"&gt;
              &lt;complexType&gt;
                  &lt;sequence&gt;
                      &lt;element minOccurs="1" name="simulationId" type="long" /&gt;
                      &lt;element minOccurs="1" name="activityId" type="long" /&gt;
                      &lt;element minOccurs="1" name="requiredPolicy" type="anyType" /&gt;
                      &lt;element minOccurs="1" name="requiredPortType" type="string" /&gt;
                      &lt;element minOccurs="1" name="requiredScope" type="anyURI" /&gt;
                  &lt;/sequence&gt;
              &lt;/complexType&gt;
          &lt;/element&gt;
      &lt;/schema&gt;
  &lt;/wsdl:types&gt;
  
  &lt;wsdl:message name="createGridRequest"&gt;
      &lt;wsdl:part name="body" element="tns:createGrid" /&gt;
      &lt;wsdl:part name="reqHeader" element="tns:requestHeader" /&gt;
  &lt;/wsdl:message&gt;
  
  &lt;wsdl:message name="createGridResponse"&gt;
      &lt;wsdl:part name="body" element="tns:createGridResponse" /&gt;
  &lt;/wsdl:message&gt;
  
  &lt;wsdl:portType name="SolverDummyProxyWSPortType"&gt;
      &lt;wsdl:operation name="createGrid"&gt;
          &lt;wsdl:input message="tns:createGridRequest" /&gt;
          &lt;wsdl:output message="tns:createGridResponse" /&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:portType&gt;
  
  &lt;wsdl:binding name="SolverDummyProxyWSSoap11Binding" type="tns:SolverDummyProxyWSPortType"&gt;
      &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /&gt;
      &lt;wsdl:operation name="createGrid"&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body parts="body" use="literal" /&gt;
              &lt;soap:header message="tns:createGridRequest" part="reqHeader"
                  use="literal" /&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body parts="body" use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  
  &lt;wsdl:binding name="SolverDummyProxyWSSoap12Binding" type="tns:SolverDummyProxyWSPortType"&gt;
      &lt;soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /&gt;
      &lt;wsdl:operation name="createGrid"&gt;
          &lt;wsdl:input&gt;
              &lt;soap12:body parts="body" use="literal" /&gt;
              &lt;soap12:header message="tns:createGridRequest" part="reqHeader"
                  use="literal" /&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap12:body parts="body" use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  
  &lt;wsdl:service name="SolverDummyProxyWS"&gt;
      &lt;wsdl:port name="SolverDummyProxyWSSoap11Endpoint" binding="tns:SolverDummyProxyWSSoap11Binding"&gt;
          &lt;soap:address location="http://localhost:8280/services/SolverDummyProxyWS.SolverDummyProxyWSSoap11Endpoint" /&gt;
      &lt;/wsdl:port&gt;
      &lt;wsdl:port name="SolverDummyProxyWSSoap12Endpoint" binding="tns:SolverDummyProxyWSSoap12Binding"&gt;
          &lt;soap12:address location="http://localhost:8280/services/SolverDummyProxyWS.SolverDummyProxyWSSoap12Endpoint" /&gt;
      &lt;/wsdl:port&gt;
  &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>So i create a Proxy using the WSO2-ESB Webinterface. If I have a look at the actual WSDL of the created Proxy, I see that WSO2-ESB did some changes:
  - Added HTTP Binding
  - Removed header-part from createGridRequest message
  - messed soap:input in bindings (there are two header definitions, and the body part was removed)</p>
  
  <p>WSDL-modified by WSO2-ESB</p>
  
  <pre><code>&lt;wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:tns="http://de.unistuttgart.iaas" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://de.unistuttgart.iaas"&gt;
  &lt;wsdl:types&gt;
      &lt;schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://de.unistuttgart.iaas"&gt;
          &lt;element name="createGrid"&gt;
              &lt;complexType&gt;
                  &lt;sequence&gt;
                      &lt;element minOccurs="0" name="milliseconds" type="long" /&gt;
                  &lt;/sequence&gt;
              &lt;/complexType&gt;
          &lt;/element&gt;
          &lt;element name="createGridResponse"&gt;
              &lt;complexType&gt;
                  &lt;sequence&gt;
                      &lt;element minOccurs="0" name="return" type="string" /&gt;
                  &lt;/sequence&gt;
              &lt;/complexType&gt;
          &lt;/element&gt;
          &lt;element name="requestHeader"&gt;
              &lt;complexType&gt;
                  &lt;sequence&gt;
                      &lt;element name="simulationId" type="long" /&gt;
                      &lt;element name="activityId" type="long" /&gt;
                      &lt;element name="requiredPolicy" type="anyType" /&gt;
                      &lt;element name="requiredPortType" type="string" /&gt;
                      &lt;element name="requiredScope" type="anyURI" /&gt;
                  &lt;/sequence&gt;
              &lt;/complexType&gt;
          &lt;/element&gt;
      &lt;/schema&gt;
  &lt;/wsdl:types&gt;
  &lt;wsdl:message name="createGridRequest"&gt;
      &lt;wsdl:part name="body" element="tns:createGrid" /&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:message name="createGridResponse"&gt;
      &lt;wsdl:part name="body" element="tns:createGridResponse" /&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:portType name="SolverDummyProxyHWSPortType"&gt;
      &lt;wsdl:operation name="createGrid"&gt;
          &lt;wsdl:input message="tns:createGridRequest" wsaw:Action="http://de.unistuttgart.iaas/SolverDummyProxyWSPortType/createGridRequest" /&gt;
          &lt;wsdl:output message="tns:createGridResponse" wsaw:Action="http://de.unistuttgart.iaas/SolverDummyProxyWSPortType/createGridResponse" /&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:portType&gt;
  &lt;wsdl:binding name="SolverDummyProxyHWSSoap11Binding" type="tns:SolverDummyProxyHWSPortType"&gt;
      &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /&gt;
      &lt;wsdl:operation name="createGrid"&gt;
          &lt;soap:operation soapAction="" style="document" /&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal" /&gt;
              &lt;soap12:header use="literal" part="reqHeader" message="tns:createGridRequest" /&gt;
              &lt;soap12:header use="literal" part="reqHeader" message="tns:createGridRequest" /&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal" /&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  &lt;wsdl:binding name="SolverDummyProxyHWSSoap12Binding" type="tns:SolverDummyProxyHWSPortType"&gt;
      &lt;soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /&gt;
      &lt;wsdl:operation name="createGrid"&gt;
          &lt;soap12:operation soapAction="" style="document" /&gt;
          &lt;wsdl:input&gt;
              &lt;soap12:body use="literal" /&gt;
              &lt;soap12:header use="literal" part="reqHeader" message="tns:createGridRequest" /&gt;
              &lt;soap12:header use="literal" part="reqHeader" message="tns:createGridRequest" /&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap12:body use="literal" /&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  &lt;wsdl:binding name="SolverDummyProxyHWSHttpBinding" type="tns:SolverDummyProxyHWSPortType"&gt;
      &lt;http:binding verb="POST" /&gt;
      &lt;wsdl:operation name="createGrid"&gt;
          &lt;http:operation location="createGrid" /&gt;
          &lt;wsdl:input&gt;
              &lt;mime:content type="text/xml" part="parameters" /&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;mime:content type="text/xml" part="parameters" /&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  &lt;wsdl:service name="SolverDummyProxyHWS"&gt;
      &lt;wsdl:port name="SolverDummyProxyHWSHttpSoap11Endpoint" binding="tns:SolverDummyProxyHWSSoap11Binding"&gt;
          &lt;soap:address location="http://Tobiass-MacBook-Pro.local:8280/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpSoap11Endpoint" /&gt;
      &lt;/wsdl:port&gt;
      &lt;wsdl:port name="SolverDummyProxyHWSHttpsSoap11Endpoint" binding="tns:SolverDummyProxyHWSSoap11Binding"&gt;
          &lt;soap:address location="https://Tobiass-MacBook-Pro.local:8243/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpsSoap11Endpoint" /&gt;
      &lt;/wsdl:port&gt;
      &lt;wsdl:port name="SolverDummyProxyHWSHttpSoap12Endpoint" binding="tns:SolverDummyProxyHWSSoap12Binding"&gt;
          &lt;soap12:address location="http://Tobiass-MacBook-Pro.local:8280/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpSoap12Endpoint" /&gt;
      &lt;/wsdl:port&gt;
      &lt;wsdl:port name="SolverDummyProxyHWSHttpsSoap12Endpoint" binding="tns:SolverDummyProxyHWSSoap12Binding"&gt;
          &lt;soap12:address location="https://Tobiass-MacBook-Pro.local:8243/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpsSoap12Endpoint" /&gt;
      &lt;/wsdl:port&gt;
      &lt;wsdl:port name="SolverDummyProxyHWSHttpsEndpoint" binding="tns:SolverDummyProxyHWSHttpBinding"&gt;
          &lt;http:address location="https://Tobiass-MacBook-Pro.local:8243/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpsEndpoint" /&gt;
      &lt;/wsdl:port&gt;
      &lt;wsdl:port name="SolverDummyProxyHWSHttpEndpoint" binding="tns:SolverDummyProxyHWSHttpBinding"&gt;
          &lt;http:address location="http://Tobiass-MacBook-Pro.local:8280/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpEndpoint" /&gt;
      &lt;/wsdl:port&gt;
  &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>This code does not have mandatory headers, so my initial purpose of creating initial headers was messed up by wso2-esb.</p>
  
  <p>Can somebody tell my how I can add mandatory headers to a proxy service (this would be the case if my initial wsdl file has errors)?</p>
  
  <p>If my initial wsdl-file was ok, how can I enforce wso2-esb to use this file, and do not modify it?!?</p>
  
  <p>Last question, is there another way of creating mandatory headers, for a request to a proxy?</p>
  
  <p>Thanks for your answers!</p>