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

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.

Related

Exposing simple types on WSDL with Spyne

We are trying to build a SOAP app with Django + Spyne building specific required endpoints. The exposed WSDL has to precisely match a predetermined XML file, including the custom simpleType definitions. We're currently failing to show the simple type definitions on our WSDL, everything else matches up precisely.
A simple example is the following hello world app:
import logging
logging.basicConfig(level=logging.DEBUG)
from spyne import Application, rpc, ServiceBase, \
Integer, Unicode, SimpleModel
from spyne import Iterable
from spyne.protocol.xml import XmlDocument
from spyne.protocol.soap import Soap11
from spyne.interface.wsdl import Wsdl11
from spyne.server.django import DjangoApplication
from django.views.decorators.csrf import csrf_exempt
class IdType(SimpleModel):
__type_name__ = "IdType"
__namespace__ = 'spyne.examples.hello'
__extends__ = Unicode
class Attributes(Unicode.Attributes):
out_type = 'TxnIdType'
class HelloWorldService(ServiceBase):
#rpc(IdType, Integer, _returns=Iterable(Unicode))
def say_hello(ctx, TxnIdType, times):
for i in range(times):
yield 'Hello, %s' % TxnIdType
application = Application([HelloWorldService],
tns='spyne.examples.hello',
interface = Wsdl11(),
in_protocol=Soap11(validator = 'lxml'),
# out_protocol=XmlDocument(validator='schema')
out_protocol=Soap11()
)
hello_app = csrf_exempt(DjangoApplication(application))
Which yields the following WSDL:
<wsdl:definitions xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:plink="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:wsdlsoap11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdlsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap11enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap12env="http://www.w3.org/2003/05/soap-envelope" xmlns:soap12enc="http://www.w3.org/2003/05/soap-encoding" xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="spyne.examples.hello/types" xmlns:s0="spyne.examples.hello" targetNamespace="spyne.examples.hello/types" name="Application">
<wsdl:types>
<xs:schema targetNamespace="spyne.examples.hello/types" elementFormDefault="qualified">
<xs:import namespace="spyne.examples.hello" />
<xs:complexType name="say_helloResponse">
<xs:sequence>
<xs:element name="say_helloResult" type="xs:string" minOccurs="0" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="say_hello">
<xs:sequence>
<xs:element name="IdType" type="s0:IdType" minOccurs="0" nillable="true" />
<xs:element name="times" type="xs:integer" minOccurs="0" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:element name="say_helloResponse" type="tns:say_helloResponse" />
<xs:element name="say_hello" type="tns:say_hello" />
</xs:schema>
</wsdl:types>
<wsdl:message name="say_hello">
<wsdl:part name="say_hello" element="tns:say_hello" />
</wsdl:message>
<wsdl:message name="say_helloResponse">
<wsdl:part name="say_helloResponse" element="tns:say_helloResponse" />
</wsdl:message>
<wsdl:service name="HelloWorldService">
<wsdl:port name="Application" binding="tns:Application">
<wsdlsoap11:address location="http://localhost:8000/gtw/services/HelloWorldService" />
</wsdl:port>
</wsdl:service>
<wsdl:portType name="Application">
<wsdl:operation name="say_hello" parameterOrder="say_hello">
<wsdl:input name="say_hello" message="tns:say_hello" />
<wsdl:output name="say_helloResponse" message="tns:say_helloResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Application" type="tns:Application">
<wsdlsoap11:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="say_hello">
<wsdlsoap11:operation soapAction="say_hello" style="document" />
<wsdl:input name="say_hello">
<wsdlsoap11:body use="literal" />
</wsdl:input>
<wsdl:output name="say_helloResponse">
<wsdlsoap11:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
As you can see, the simpleType "IdType" does not show up. Is there a way to force Spyne to reflect these tags? Currently our output WSDL does not pass the required validation since it does not recognize the custom simpleTypes.
Our expected output is the following:
<simpleType name="IdType">
<restriction base="xsd:string">
<xsd:maxLength value="10"/>
</restriction>
</simpleType>
Any help will be greatly appreciated.
Thanks!
So you're this guy right? https://github.com/arskom/spyne/discussions/681
Pasting my response here as well. Hope you care to reply this time.
=================
Did you read this? http://spyne.io/docs/2.10/manual/03_types.html#customization
IdType = Unicode(10, type_name='IdType')
class HelloWorldService(ServiceBase):
#rpc(IdType, Integer, _returns=Iterable(Unicode))
def say_hello(ctx, TxnIdType, times):
for i in range(times):
yield 'Hello, %s' % TxnIdType
Does this produce the wsdl you need?

How to see ARRAY with NODE JS soap

Hi need to make a WebService with nodejs, this is my first experience to make a SOAP with WSDL.
I use the library "node-wsdl" and i need to stamp a list of array in soap but now i receive a wrong response
I have this response from SOAP:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://localhost:3001/gateway">
<soap:Body>
<tns:listInvoicesResponse>
<tns:0>
<invoice_id>00000</invoice_id>
<ipa_code>00000</ipa_code>
<timing>Thu Jun 04 2015 16:35:46 GMT+0100 (GMT+01:00)</timing>
</tns:0>
<tns:1>
<invoice_id>00001</invoice_id>
<ipa_code>00001</ipa_code>
<timing>Thu Jun 04 2015 16:41:29 GMT+0100 (GMT+01:00)</timing>
</tns:1>
</tns:listInvoicesResponse>
</soap:Body>
</soap:Envelope>
But i need to have a response like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://localhost:3001/gateway">
<soap:Body>
<tns:listInvoicesResponse>
<lists>
<tns:0>
<invoice_id>00000</invoice_id>
<ipa_code>00000</ipa_code>
<timing>Thu Jun 04 2015 16:35:46 GMT+0100 (GMT+01:00)</timing>
</tns:0>
<tns:1>
<invoice_id>000</invoice_id>
<ipa_code>00001</ipa_code>
<timing>Thu Jun 04 2015 16:41:29 GMT+0100 (GMT+01:00)</timing>
</tns:1>
</lists>
</tns:listInvoicesResponse>
</soap:Body>
</soap:Envelope>
I use this code for retrive info from a DB and print the result on XML like list
var myService = {
ws: {
gateway: {
listInvoices: function(args, callback) {
var ipa_code = args.ipaCode
GetAllInvoice(ipa_code).then(result =>{
console.log(result)
result.map( el =>{
callback(result)
})
})
},
// This is how to define an asynchronous function.
getInvoice: function(args, callback) {
// do some work
}
}
}
};
And my wsdl is this
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="InvoiceGeneral"
targetNamespace="http://localhost:3001/gateway"
xmlns="http://localhost:3001/gateway"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:tns="http://localhost:3001/gateway"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wsdl:message name="listInvoicesRequest">
<wsdl:part name="ipaCode" type="xs:string"/>
<wsdl:part name="dateFrom" type="xs:string"/>
<wsdl:part name="dateTo" type="xs:string"/>
<wsdl:part name="Accepted_invoice" type="xs:string"/>
</wsdl:message>
<wsdl:message name="getInvoiceRequest">
<wsdl:part name="ipaCode" type="xs:string"/>
<wsdl:part name="refId" type="xs:string"/>
</wsdl:message>
<wsdl:message name="listInvoicesResponse">
<wsdl:part name="InvoiceList" type="tns:string"/>
</wsdl:message>
<wsdl:message name="getInvoiceResponse">
<wsdl:part name="DocInvoice" type="xs:string"/>
<wsdl:part name="descres" type="xs:string"/>
<wsdl:part name="resultCode" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="gatewayP">
<wsdl:operation name="listInvoices">
<wsdl:input message="listInvoicesRequest"/>
<wsdl:output message="listInvoicesResponse"/>
</wsdl:operation>
<wsdl:operation name="getInvoice">
<wsdl:input message="getInvoiceRequest"/>
<wsdl:output message="getInvoiceResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Gateways" type="gatewayP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="listInvoices">
<soap:operation soapAction="listInvoices"/>
<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:operation name="getInvoice">
<soap:operation soapAction="getInvoice"/>
<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="Gateways" name="gateway">
<soap:address location="http://localhost:3001/WebServices/InvoiceGeneral"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Soap Webservice in Node JS

I am trying to build a soap webservice in node js using the npm module soap. I am using the soap.listen function that is mentioned to launch a soap server in node js. The wsdl file I am including looks like below:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="wscalc1" targetNamespace="http://localhost:8100/api/orderStatusWsdl" xmlns="http://localhost:8100/api/orderStatusWsdl" 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="receiveOrderStatusRequest">
<wsdl:part name="a" type="xs:string"/>
<wsdl:part name="b" type="xs:string"/>
</wsdl:message>
<wsdl:message name="receiveOrderStatusResponse">
<wsdl:part name="orderStatusResponse" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="orderStatusPort">
<wsdl:operation name="receiveOrderStatus">
<wsdl:input message="receiveOrderStatusRequest"/>
<wsdl:output message="receiveOrderStatusResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="orderStatusBinding" type="orderStatusPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="receiveOrderStatus">
<soap:operation soapAction="receiveOrderStatus"/>
<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="orderStatusService">
<wsdl:port binding="orderStatusBinding" name="orderStatus">
<soap:address location="http://localhost:8100/api/orderStatusWsdl"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The node js code:
var orderStatusWsdlXml = fs.readFileSync(path.join(__dirname, 'soap/wsdl/myWsdl2.wsdl'), 'utf8')
var soapServer = soap.listen(server, BASE_URL + '/orderStatusWsdl', orderStatusSoapService, orderStatusWsdlXml2)
soapServer.log = function(type, data) {
log.d('TYPE: ' + type)
log.d('DATA: ' + JSON.stringify(data, null, 4))
}
After running the node project I try to load the WSDL in SOAP UI client and I get the following error:
Error loading [http://localhost:8100/api/orderStatusWsdl]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after null
Where am I going wrong?

how to use nodejs send soap complextype to axis wsdl server

I'm using node as client communicate with java axis wsdl service (not familiar to this).
There is a node-soap module could send simple types to service. e.g:
<wsdl:message name="helloArgsRequest">
<wsdl:part name="str" type="xsd:string"/>
<wsdl:part name="i" type="xsd:int"/>
</wsdl:message>
<!-- ... -->
<wsdl:operation name="helloArgs" parameterOrder="str i">
<wsdl:input message="impl:helloArgsRequest" name="helloArgsRequest"/>
<wsdl:output message="impl:helloArgsResponse" name="helloArgsResponse"/>
</wsdl:operation>
node:
soap.createClient(url, function(err, client) {
client.helloArgs({
str: "haha",
i: 100
}, function(err, result) {
console.log(result); // OK
});
});
But node-soap does not support complexType (Cannot find any example about complexType). So I capture the http request and get raw xml data post to service, as follow:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:impl="http://192.168.0.3:8080/axis/LoginService.jws" xmlns:intf="http://192.168.0.3:8080/axis/LoginService.jws" xmlns:tns1="http://DefaultNamespace">
<soap:Body>
<impl:helloArgs>
<str>haha</str>
<code>1</code>
</impl:helloArgs>
</soap:Body>
</soap:Envelope>
I write a test method helloJSON apply an argument typeof JSONObject. Change the xml data as follow. Unlucky, it not work.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:impl="http://192.168.0.3:8080/axis/LoginService.jws" xmlns:intf="http://192.168.0.3:8080/axis/LoginService.jws" xmlns:tns1="http://DefaultNamespace">
<soap:Body>
<impl:helloJSON>
<arg type="tns1:JSONResult">
<code>1</code>
<data>Hello</data>
<message>dhad</message>
</arg>
</impl:helloJSON>
</soap:Body>
</soap:Envelope>
The service response:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">localhost.localdomain</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Could somebody give me some example of the raw xml send complexType data to axis service, thanks.
PS: the whole wsdl service description
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://192.168.0.3:8080/axis/LoginService.jws" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://192.168.0.3:8080/axis/LoginService.jws" xmlns:intf="http://192.168.0.3:8080/axis/LoginService.jws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://DefaultNamespace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="JSONResult">
<sequence>
<element name="code" type="xsd:int"/>
<element name="data" nillable="true" type="xsd:anyType"/>
<element name="message" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="helloJSONResponse">
<wsdl:part name="helloJSONReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="helloArgsRequest">
<wsdl:part name="str" type="xsd:string"/>
<wsdl:part name="i" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="helloArgsResponse">
<wsdl:part name="helloArgsReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="helloJSONRequest">
<wsdl:part name="arg" type="tns1:JSONResult"/>
</wsdl:message>
<wsdl:portType name="LoginService">
<wsdl:operation name="helloJSON" parameterOrder="arg">
<wsdl:input message="impl:helloJSONRequest" name="helloJSONRequest"/>
<wsdl:output message="impl:helloJSONResponse" name="helloJSONResponse"/>
</wsdl:operation>
<wsdl:operation name="helloArgs" parameterOrder="str i">
<wsdl:input message="impl:helloArgsRequest" name="helloArgsRequest"/>
<wsdl:output message="impl:helloArgsResponse" name="helloArgsResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LoginServiceSoapBinding" type="impl:LoginService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="helloJSON">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="helloJSONRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="helloJSONResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.0.3:8080/axis/LoginService.jws" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="helloArgs">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="helloArgsRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="helloArgsResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.0.3:8080/axis/LoginService.jws" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="LoginServiceService">
<wsdl:port binding="impl:LoginServiceSoapBinding" name="LoginService">
<wsdlsoap:address location="http://192.168.0.3:8080/axis/LoginService.jws"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

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