I would guess that Axis couldn't figure out how to serialize a TSecurity instance. You'd need to define the type mapping to Axis. This can be done with a registerTypeMapping call on the Call object, or through the client-config.wsdd file. If the standard Axis serializers can't handle it, you'll have to write your own serializer. If it needs to be deserialized at the server, you might need corresponding mappings at the server.
Alternatively, Axis has a standard way of passing username and password, using HTTP basic authorization. just use the setUsername and setPassword methods on the Call object and retrieve the values from the MessageContext object on the server.
Also, you might want to consider adding headers via Handlers, instead of in the main client code.
Tony
I've searched through the archives but I haven't found anyone trying to do something similar.
I need to build a custom header like this example I was provided with below.
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoaporg/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:Header SOAP-ENV:encodingStyle="http://schemas.xmlsoaporg/soap/encoding/" xmlns:NS1="urn:uGlobalSOAPTypes">
<NS1:TSecurity xsi:type="NS1:TSecurity">
<UserName xsi:type="xsd:string">VGVzdFVzZXJ=</UserName>
<Password xsi:type="xsd:string">VGVzdFBhc3N3b3Jk</Password>
</NS1:TSecurity></SOAP-ENV:Header>
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<NS2:GetVersion xmlns:NS2="urn:uOBI_Intf-IOBISMSClient"/>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
I've been trying to do this with this snippet of code:
this.security = new TSecurity(this.username, this.password);
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(url));
call.setOperationName(new javax.xml.namespace.QName("urn:uOBI_Intf-IOBISMSClient", "GetVersion"));
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
SOAPHeaderElement header = new SOAPHeaderElement("urn:uGlobalSOAPTypes", "TSecurity", security);
call.addHeader(header);
call.setMaintainSession(false);
call.setStreaming(true);
String reply = (String)call.invoke(new Object[] {});
But the XML I'm creating looks like this? What am I doing wrong? Or should this message be compatible?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoaporg/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:TSecurity soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" href="" xmlns:ns1="urn:uGlobalSOAPTypes"/>
</soapenv:Header>
<soapenv:Body>
<ns2:GetVersion soapenv:encodingStyle="http://schemas.xmlsoaporg/soap/encoding/" xmlns:ns2="urn:uOBI_Intf-IOBISMSClient"/>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoaporg/soap/encoding/" xsi:type="ns3:TSecurity" xmlns:soapenc="http://schemas.xmlsoaporg/soap/encoding/" xmlns:ns3="urn:uGlobalSOAPTypes">
<UserName xsi:type="xsd:string">VGVzdFVzZXJ=</UserName>
<Password xsi:type="xsd:string">VGVzdFBhc3N3b3Jk</Password>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
- Yet another Custom Header question Kevin J. Duling
- Re: Yet another Custom Header question tony . q . weddle
- Re: Yet another Custom Header question Kevin J. Duling
- Re: Yet another Custom Header question tony . q . weddle
- Re: Yet another Custom Header question Kevin Duling