so I'm trying to execute the following
soapClient.getDeptUser({
UserName : "temp",
UserPassword : "temp"
},
userNumber : "xxxxxx"
}}, (err,result) => {
if(err){
console.log(soapClient.lastRequest);
}else{
console.log(result);
}
});
But I keep getting the error from the web service as: Cannot identify any WSDL operation from request.
My last request looks like this:
<soap:Body Id="_0">
<getDeptUserRequest>
<User>
<UserName>temp</UserName>
<UserPassword>temp</UserPassword
</User>
<userNumber>xxxxx</userNumber>
</getDeptUserRequest>
</soap:Body>
I think the problem is because there is no method called getDeptUserRequest but I'm trying to call getDeptUser not sure how to prevent the word Request from being appended onto the method name.
WSDL
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://webservices.cxfdept.fbem"
xmlns:tns1="http://pojo.webservices.cxf.fbem"
xmlns:schema="http://methods.webservices.cxf.fbem"
xmlns:tns="http://webservices.cxfdept.fbem"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<!-- ****************************************************** -->
<!-- *** import complex types definitions for this XSD ***-->
<!-- ****************************************************** -->
<wsdl:import namespace="http://methods.webservices.cxf.fbem" location="WsFBEMDept_methods_01.xsd"></wsdl:import>
<!-- *************************************************** -->
<!-- ******* Set messages ****************************-->
<!-- *************************************************** -->
<!-- getDeptUserRequest -->
<wsdl:message name="getDeptUserRequest">
<wsdl:part name="parameters" element="schema:getDeptUser"/>
</wsdl:message>
<wsdl:message name="getDeptUserResponse">
<wsdl:part name="parameters" element="schema:getDeptUserResponse"/>
</wsdl:message>
<!-- ****************************************************** -->
<!-- ******* Set portTypes *** -->
<!-- ****************************************************** -->
<wsdl:portType name="WsFBEMDeptServiceV1001PortType">
<wsdl:operation name="getDeptUser">
<wsdl:input name="getDeptUserRequest" message="tns:getDeptUserRequest"/>
<wsdl:output name="getDeptUserResponse" message="tns:getDeptUserResponse"/>
</wsdl:operation>
<!-- ****************************************************** -->
<!-- **** Set Bindings *** -->
<!-- ****************************************************** -->
<wsdl:binding name="WsFBEMDeptServiceV1001HttpBinding" type="tns:WsFBEMDeptServiceV1001PortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<!-- getDeptUser -->
<wsdl:operation name="getDeptUser">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getDeptUserRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getDeptUserResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<!-- ****************************************************** -->
<!-- *** Set Service *** -->
<!-- ****************************************************** -->
<wsdl:service name="WsFBEMDeptServiceV1001">
<wsdl:port name="WsFBEMDeptServiceV1001HttpPort" binding="tns:WsFBEMDeptServiceV1001HttpBinding">
<wsdlsoap:address location="http://127.0.0.1:8080/fbem_cxfDept/services/WsFBEMDeptServiceV1001"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Related
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>
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?
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>
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.
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;