How to create a SOAP Request BODY from JSON? - node.js

I have created a node.js application to create a SOAP Request BODY from a JSON object. I have the following code
var convert = require('xml-js');
var xml = `<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/" xmlns:tel="http://schemas.datacontract.org"
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/>
<soapenv:Body>
<tem:MyRequest>
<tem:request>
<tel:MyTag1>null</tel:MyTag1>
<tel:MyTag2>12</tel:MyTag2>
<tel:MyTag3>MyValue1</tel:MyTag3>
<tel:MyTag4><arr:int>1000</arr:int>
<arr:int>1001</arr:int><arr:int>1002</arr:int>
</tel:MyTag4>
</tem:request>
</tem:MyRequest>
</soapenv:Body>
</soapenv:Envelope>`;
var options = { ignoreComment: false, alwaysChildren: true };
var result1 = convert.xml2js(xml, options);
console.log("json = ",JSON.stringify(result1));
var options2 = {compact: true, ignoreComment: true, spaces: 4};
var result2 = convert.json2xml(result1, options2);
console.log("xml ==> ",result2);
I got output like this
json = {"elements":[{"type":"element","name":"soapenv:Envelope","attributes":{"xmlns:soapenv":"http://schemas.xmlsoap.org/soap/envelope/","xmlns:tem":"http://tempuri.org/","xmlns:tel":"http://schemas.datacontract.org","xmlns:arr":"http://schemas.microsoft.com/2003/10/Serialization/Arrays"},"elements":[{"type":"element","name":"soapenv:Header","elements":[]},{"type":"element","name":"soapenv:Body","elements":[{"type":"element","name":"tem:MyRequest","elements":[{"type":"element","name":"tem:request","elements":[{"type":"element","name":"tel:MyTag1","elements":[{"type":"text","text":"null"}]},{"type":"element","name":"tel:MyTag2","elements":[{"type":"text","text":"12"}]},{"type":"element","name":"tel:MyTag3","elements":[{"type":"text","text":"MyValue1"}]},{"type":"element","name":"tel:MyTag4","elements":[{"type":"element","name":"arr:int","elements":[{"type":"text","text":"1000"}]},{"type":"element","name":"arr:int","elements":[{"type":"text","text":"1001"}]},{"type":"element","name":"arr:int","elements":[{"type":"text","text":"1002"}]}]}]}]}]}]}]}
xml ==> <elements>
<type>element</type>
<name>soapenv:Envelope</name>
<attributes>
<xmlns:soapenv>http://schemas.xmlsoap.org/soap/envelope/</xmlns:soapenv>
<xmlns:tem>http://tempuri.org/</xmlns:tem>
<xmlns:tel>http://schemas.datacontract.org</xmlns:tel>
<xmlns:arr>http://schemas.microsoft.com/2003/10/Serialization/Arrays</xmlns:arr>
</attributes>
<elements>
<type>element</type>
<name>soapenv:Header</name>
</elements>
<elements>
<type>element</type>
<name>soapenv:Body</name>
<elements>
<type>element</type>
<name>tem:MyRequest</name>
<elements>
<type>element</type>
<name>tem:request</name>
<elements>
<type>element</type>
<name>tel:MyTag1</name>
<elements>
<type>text</type>
<text>null</text>
</elements>
</elements>
<elements>
<type>element</type>
<name>tel:MyTag2</name>
<elements>
<type>text</type>
<text>12</text>
</elements>
</elements>
<elements>
<type>element</type>
<name>tel:MyTag3</name>
<elements>
<type>text</type>
<text>MyValue1</text>
</elements>
</elements>
<elements>
<type>element</type>
<name>tel:MyTag4</name>
<elements>
<type>element</type>
<name>arr:int</name>
<elements>
<type>text</type>
<text>1000</text>
</elements>
</elements>
<elements>
<type>element</type>
<name>arr:int</name>
<elements>
<type>text</type>
<text>1001</text>
</elements>
</elements>
<elements>
<type>element</type>
<name>arr:int</name>
<elements>
<type>text</type>
<text>1002</text>
</elements>
</elements>
</elements>
</elements>
</elements>
</elements>
</elements>
There is a mismatch from input xml and final xml. why this?

Related

Namespace coming as undefined in the response body for soap in node js.

I am using node js with the soap module 'node-soap' version 0.24.0 (latest).
I am implementing a api framework with the following wsdl file, server.js file. For organisational reasons the wsdl operation is just like a sample template similar to structure of original code.When I make a SOAP request, its being processed successfully but in the response , namespace part in the tags is coming as undefined. This is causing problems to our client who will be making the api calls, they are not able to read the response properly.
I am unable to find a fix for this and do not know if I shoukld change something in the wsdl file or the server.js.
wscalc1.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="wscalc1" targetNamespace="http://localhost:8000/wscalc1"
xmlns="http://localhost:8000/wscalc1"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="multiplicarRequest">
<wsdl:part name="a" type="xs:string"/>
<wsdl:part name="b" type="xs:string"/>
</wsdl:message>
<wsdl:message name="multiplicarResponse">
<wsdl:part name="mulres" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="calcP">
<wsdl:operation name="multiplicar">
<wsdl:input message="multiplicarRequest"/>
<wsdl:output message="multiplicarResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="calcB" type="calcP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="multiplicar">
<soap:operation soapAction="multiplicar"/>
<wsdl:input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="calcB" name="calc">
<soap:address location="http://localhost:8001/wscalc1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
server.js
"use strict";
var soap = require('soap');
var http = require('http');
var service = {
ws: {
calc: {
multiplicar : function(args) {
var n = args.a * args.b;
return { mulres : n };
}
}
}
};
var xml = require('fs').readFileSync('wscalc1.wsdl', 'utf8');
var server = http.createServer(function(request,response) {
response.end("404: Not Found: "+request.url);
});
server.listen(8001);
soap.listen(server, '/wscalc1', service, xml);
post request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsc="http://localhost:8000/wscalc1">
<soapenv:Header/>
<soapenv:Body>
<wsc:multiplicar>
<a>2</a>
<b>3</b>
</wsc:multiplicar>
</soapenv:Body>
</soapenv:Envelope>
response
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Body>
<undefined:multiplicarResponse>
<undefined:mulres>6</undefined:mulres>
</undefined:multiplicarResponse>
</soap:Body>
</soap:Envelope>
I had the same issue. I'm not sure how to apply my solution to your code, but the idea is that you need to specify your namespace in <definitions> tag and assign a prefix for it, like:
<definitions
name="ININWebService"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="WebServices.TVTraffic"
targetNamespace="WebServices.TVTraffic"
>
Then I used the same prefix 'tns' to define my messages and elements, like element="tns:updatePayment" instead of element="updatePayment" and so on, and finally I've got working namespace prefixes.
Hope it helps.
I have been able to make it work, but I had to do some changes to the wsdl, I also used Eclipse wsdl editor to verify if there are any error. Please find the details below:
wscalc1.wsdl
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8000/wscalc1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="wscalc1" targetNamespace="http://localhost:8000/wscalc1">
<wsdl:message name="sumarRequest">
<wsdl:part name="a" type="xsd:string"></wsdl:part>
<wsdl:part name="b" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="sumarResponse">
<wsdl:part name="sumres" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="multiplicarRequest">
<wsdl:part name="a" type="xsd:string"></wsdl:part>
<wsdl:part name="b" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="multiplicarResponse">
<wsdl:part name="mulres" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:portType name="calcP">
<wsdl:operation name="sumar">
<wsdl:input message="tns:sumarRequest"></wsdl:input>
<wsdl:output message="tns:sumarResponse"/>
</wsdl:operation>
<wsdl:operation name="multiplicar">
<wsdl:input message="tns:multiplicarRequest"></wsdl:input>
<wsdl:output message="tns:multiplicarResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="calcB" type="tns:calcP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sumar">
<soap:operation soapAction="sumar" style="rpc"/>
<wsdl:input>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplicar">
<soap:operation soapAction="multiplicar" style="rpc"/>
<wsdl:input>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="tns:calcB" name="calc">
<soap:address location="http://localhost:8001/wscalc1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
server.js
const soap = require('soap');
const http = require('http');
const service = {
ws: {
calc: {
sumar : function(args) {
var n = 1*args.a + 1*args.b;
return { sumres : n };
},
multiplicar : function(args) {
var n = args.a * args.b;
return { mulres : n };
}
}
}
};
const xml = require('fs').readFileSync('wscalc1.wsdl', 'utf8');
const server = http.createServer(function(request,response) {
response.end("404: Not Found: "+request.url);
});
server.listen(8001);
soap.listen(server, '/wscalc1', service, xml);
soap request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsc="http://localhost:8000/wscalc1">
<soapenv:Header/>
<soapenv:Body>
<wsc:sumar>
<a>2</a>
<b>3</b>
</wsc:sumar>
</soapenv:Body>
</soapenv:Envelope>
response
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://localhost:8000/wscalc1">
<soap:Body>
<tns:sumarResponse>
<tns:sumres>5</tns:sumres>
</tns:sumarResponse>
</soap:Body>
</soap:Envelope>

Check security header in Mule http:listener

I have a need to check some security HTTP header (called for example X-MyApp-Security) value before processing it after Mule http:listener. Header should be checked like basic auth header but more simply.
I found some Mule documentation about this but don't understand how to use it my simple flow:
<http:listener-config name="HTTP_Listener_Configuration" host="${httpServer.host}" port="${httpServer.port}" doc:name="HTTP Listener Configuration" />
<flow name="planadoWebhookFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP" allowedMethods="POST"/>
<set-payload value="Hello from security area!" doc:name="Set Payload"/>
</flow>
Please help me with header authentication in Mule 3.7.
You can use the "http:basic-security-filter" element, here you have an example:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp"
xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:mule-xml="http://www.mulesoft.org/schema/mule/xml"
xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:ws="http://www.mulesoft.org/schema/mule/ws"
xmlns:smtps="http://www.mulesoft.org/schema/mule/smtps"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:mule-ss="http://www.mulesoft.org/schema/mule/spring-security"
xmlns:ss="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/smtps http://www.mulesoft.org/schema/mule/smtps/current/mule-smtps.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd
http://www.mulesoft.org/schema/mule/spring-security http://www.mulesoft.org/schema/mule/spring-security/3.1/mule-spring-security.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
">
<spring:beans>
<ss:authentication-manager alias="authenticationManager">
<ss:authentication-provider>
<ss:user-service id="userService">
<ss:user name="user" password="password" authorities="ROLE_ADMIN" />
<ss:user name="anon" password="anon" authorities="ROLE_ANON" />
</ss:user-service>
</ss:authentication-provider>
</ss:authentication-manager>
</spring:beans>
<mule-ss:security-manager>
<mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />
</mule-ss:security-manager>
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="9091" doc:name="HTTP Listener Configuration"/>
<flow name="testingFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/*" doc:name="HTTP"/>
<logger message="Before Authentication" level="INFO" doc:name="Log Failure"/>
<http:basic-security-filter realm="mule-realm"/>
<logger message="After Authentication" level="INFO" doc:name="Log Failure"/>
</flow>
</mule>
You can find more information in the next link:
https://docs.mulesoft.com/mule-user-guide/v/3.7/http-listener-connector#authentication

SOAPUI - missing message part with name - schema compliance error

Here is the wsdl file with the schema inline. I have the actual wsdl file being called locally aka localhost/wsdl/.
<wsdl:definitions xmlns="http://soap.company.com/fetch_n_pay"
xmlns:tns="http://soap.company.com/fetch_n_pay"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://soap.company.com/fetch_n_pay">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://soap.company.com/fetch_n_pay">
<s:complexType name="fetchBookingDetailsRequType">
<s:all>
<s:element name="version" type="s:string"/>
<s:element name="timestamp" type="s:dateTime"/>
<s:element name="siteUrl" type="s:string"/>
<s:element name="confirmationCode" type="s:string"/>
<s:element name="vendorCode" type="s:string"/>
</s:all>
</s:complexType>
<s:complexType name="fetchBookingDetailsRespType">
<s:all>
<s:element name="version" type="s:string"/>
<s:element name="timestamp" type="s:dateTime"/>
<s:element name="isSuccess" type="s:boolean"/>
<s:element name="responseCode" type="s:int"/>
<s:element name="errorMessage" type="s:string"/>
<s:element name="sailingDate" type="s:date"/>
<s:element name="sailingName" type="s:string"/>
<s:element name="cruiselineName" type="s:string"/>
<s:element name="cruiselineId" type="s:string"/>
<s:element name="cabinNumber" type="s:string"/>
<s:element name="roomType" type="s:string"/>
<s:element name="shipName" type="s:string"/>
<s:element name="departingFrom" type="s:string"/>
<s:element name="returnDate" type="s:date"/>
<s:element name="numberOfAdults" type="s:int"/>
<s:element name="numberOfChildren" type="s:int"/>
<s:element name="numberOfSeniors" type="s:int"/>
<s:element name="numberOfInfants" type="s:int"/>
<s:element name="confirmationNumber" type="s:string"/>
<s:element name="balanceDueDate" type="s:dateTime"/>
<s:element name="depositDueDate" type="s:dateTime"/>
<s:element name="depositCollectedByCruiseline" type="s:boolean"/>
<s:element name="wasBookedSuccess" type="s:boolean"/>
<s:element name="shipImageUrl" type="s:string"/>
<s:element name="isCancelled" type="s:boolean"/>
<s:element name="insuranceAmount" type="s:double"/>
<s:element name="customerTitle" type="s:string"/>
<s:element name="customerFirstName" type="s:string"/>
<s:element name="customerLastName" type="s:string"/>
<s:element name="customerPhone" type="s:string"/>
<s:element name="customerEmail" type="s:string"/>
</s:all>
</s:complexType>
<s:element name="fetchBookingDetailsRequElement" type="tns:fetchBookingDetailsRequType" />
<s:element name="fetchBookingDetailsRespElement" type="tns:fetchBookingDetailsRespType" />
</s:schema>
</wsdl:types>
<wsdl:message name="fetchBookingDetailsSoapIn">
<wsdl:part name="banana1" element="tns:fetchBookingDetailsRequElement"/>
</wsdl:message>
<wsdl:message name="fetchBookingDetailsSoapOut">
<wsdl:part name="banana2" element="tns:fetchBookingDetailsRespElement"/>
</wsdl:message>
<wsdl:portType name="FetchAndPaySoap">
<wsdl:operation name="fetchBookingDetails">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Gets Information for booking.
</wsdl:documentation>
<wsdl:input message="tns:fetchBookingDetailsSoapIn"/>
<wsdl:output message="tns:fetchBookingDetailsSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="FetchAndPaySoap" type="tns:FetchAndPaySoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="fetchBookingDetails">
<soap:operation soapAction="http://soap.company.com/fetchBookingDetails" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="FetchAndPay">
<wsdl:port name="FetchAndPaySoap" binding="tns:FetchAndPaySoap">
<soap:address location="localhost/wsdl/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
1) For some reason the request soap is adding in "fet:" namespace
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fet="http://soap.company.com/fetch_n_pay">
<soapenv:Header/>
<soapenv:Body>
<fet:fetchBookingDetailsRequElement>
<!--You may enter the following 5 items in any order-->
<fet:version>?</fet:version>
<fet:timestamp>?</fet:timestamp>
<fet:siteUrl>?</fet:siteUrl>
<fet:confirmationCode>?</fet:confirmationCode>
<fet:vendorCode>?</fet:vendorCode>
</fet:fetchBookingDetailsRequElement>
</soapenv:Body>
</soapenv:Envelope>
2) The SOAP Response is valid but the schema Compliance failed. This is the error:
SOAP Response - VALID
Schema Compliance - FAILED
-> line -1: Missing message part with name [{http://soap.company.com/fetch_n_pay}fetchBookingDetailsRespElement]
Here is the response:
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<fetchBookingDetailsResponse
xmlns="http://soap.company.com/fetch_n_pay">
<version>0.1.0</version>
<timestamp>2015-06-18T13:37:08-04:00</timestamp>
<isSuccess>false</isSuccess>
<responseCode>47</responseCode>
<errorMessage>No results were found.</errorMessage>
</fetchBookingDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Im trying to be Schema Compliant so that this can be parsed.
Anything would be greatly appreciated. Thank you!
Your validation engine already gave you the answer, it's not fetchBookingDetailsResponse, it's fetchBookingDetailsRespElement.

WSO2 BPS: How to pass Header values as a part of a Message in BPEL Invoke

My web service operation is defined like below. Where I have a header parameter as well.
public void method(#WebParam(name="OrderNo", mode=WebParam.Mode.IN) String order_no_,
#WebParam(name="user", mode=WebParam.Mode.IN, header=true) String user)
Now when I deploy this service I get a WSDL which looks like this.
<?xml version="1.0" ?>
<wsdl:definitions ... >
<wsdl:types>
</xs:schema>
...
<xs:element name="method" type="tns:method"></xs:element>
<xs:complexType name="method">
<xs:sequence>
<xs:element minOccurs="0" name="OrderNo" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
...
<xs:element name="user" nillable="true" type="xs:string"></xs:element>
...
</xs:schema>
</wsdl:types>
...
<wsdl:message name="method">
<wsdl:part element="tns:method" name="parameters" />
<wsdl:part element="tns:user" name="user" />
</wsdl:message>
...
<wsdl:portType name="CustomerOrderService">
<wsdl:operation name="method">
<wsdl:input message="tns:method" name="method" />
<wsdl:output ... />
<wsdl:fault ... />
</wsdl:operation>
</wsdl:portType>
...
<wsdl:binding name="OrderSoapBinding" type="tns:OrderService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="method">
<soap:operation soapAction="" style="document" />
<wsdl:input name="method">
<soap:header message="tns:method" part="user" use="literal" />
<soap:body parts="parameters" use="literal" />
</wsdl:input>
<wsdl:output name="...">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="...">
...
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
As you can see the header is part of the message used as input for the service request. Hwen I use soap UI to test this WSDL it generated a proper soap message with the "user" property as part of the header.
When I use this service as a partner link in a Carbon BPEL process, and assign a value to the "user" part in the invoke message, the value is not included in the header.
<bpel:variable name="method_Input" messageType="ns0:method" />
<bpel:assign name="...">
...
<bpel:copy>
<bpel:from>$input.payload/tns:TaskReceiver</bpel:from>
<bpel:to>$method_Input.user</bpel:to>
</bpel:copy>
</bpel:assign>
You can see that the message part is assigned the proper value,
The problem is this message part which is bound to the header of of the soap message is never included in the soap header.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<method xmlns="http://customerorder.service.test/">
<OrderNo xmlns="">ORD00011</OrderNo>
</method>
</soapenv:Body>
</soapenv:Envelope>
Thanks in advance to any help provided.

Nillable SOAP headers

I would like to allow some of my SOAP header elements to be nillable. This is possible for body elements, but I am not sure if it is allowed from header elements.
In the sample message below, I would like to allow the MessageDateTime to be null.
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://mycompany.com/repositoryservice">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://mycompany.com/repositoryservice">
<element name="MessageDateTime" type="dateTime" />
<element name="SaveRequest">
<!-- complexType -->
</element>
</schema>
</types>
<message name="SaveRequest_Headers">
<part name="MessageDateTime" element="tns:MessageDateTime" />
</message>
<message name="SaveRequest">
<part name="parameters" element="tns:SaveRequest" />
</message>
<binding name="RepositoryServiceBinding" type="tns:IRepositoryService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="Save">
<soap:operation soapAction="http://mycompany.com/repositoryservice/Save" style="document" />
<input name="SaveRequest">
<soap:header message="tns:SaveRequest_Headers" part="MessageDateTime" use="literal" />
<soap:body use="literal" />
</input>
</operation>
</binding>
<!-- service, portType -->
</definitions>
It is allowed as long as the definition allows for it. In your case, all you have to do is add the nillable="true" to the element's definition. The result on .NET w/ WCF would look something like this:
[System.ServiceModel.MessageHeaderAttribute(Namespace="...")]
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public System.Nullable<System.DateTime> MessageDateTime;

Resources