axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Yet another Custom Header question
Date Wed, 10 Nov 2004 09:04:21 GMT
I didn't see that href before. I have no idea why Axis is doing that. Try 
creating the complete header, before passing it to the Call object, 
something like:

            SOAPHeaderElement header = new SOAPHeaderElement( "
urn:uGlobalSOAPTypes", "TSecurity" );
            try {
                SOAPElement child;
                child = header.addChildElement( "UserName");
                child.addTextNode( this.username );
                child = header.addChildElement( "Password");
                child.addTextNode( this.password );
            } catch ( SOAPException e ) {
                throw new AxisFault( "Error adding security header", e );

If that doesn't work, try writing a handler and add the header directly to 
the SOAP envelope there, perhaps passing the user name and password (or a 
TSecurity object) in the message context.


Call.registerTypeMapping is being called for TSecurity in the Stub class 
in Stub.createCall().  I've walked through that code and see it's being 
properly set.
HTTP Basic authorization isn't an option, unfortunately.  The other side 
has elected to enforce authentication through this custom header.
What appears to be happening in Axis is that there's an href set in the 
header which is referencing an item in the SOAP body.  The other company 
has told me that this will not work and they insist the TSecurity object 
must be in the header portion.  And I can't figure out how to do that.
----- Original Message ----- 
Sent: Tuesday, November 09, 2004 12:24 AM
Subject: Re: Yet another Custom Header question

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. 


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 
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="
http://schemas.xmlsoaporg/soap/envelope/" xmlns:xsd="" xmlns:xsi="" xmlns:SOAP-ENC=""> 
    <SOAP-ENV:Header SOAP-ENV:encodingStyle="
        <NS1:TSecurity xsi:type="NS1:TSecurity"> 
            <UserName xsi:type="xsd:string">VGVzdFVzZXJ=</UserName> 
            <Password xsi:type="xsd:string">VGVzdFBhc3N3b3Jk</Password> 
    <SOAP-ENV:Body SOAP-ENV:encodingStyle=""> 
    <NS2:GetVersion xmlns:NS2="urn:uOBI_Intf-IOBISMSClient"/> 
I've been trying to do this with this snippet of code:  = new TSecurity(this.username, this.password); 
      Service service = new Service(); 
      Call call = (Call) service.createCall(); 
javax.xml.namespace.QName("urn:uOBI_Intf-IOBISMSClient", "GetVersion"));
     SOAPHeaderElement header = new 
SOAPHeaderElement("urn:uGlobalSOAPTypes", "TSecurity", security);
     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="" xmlns:xsi=""> 
        <ns1:TSecurity soapenv:actor="" soapenv:mustUnderstand="0" 
href="#id0" xmlns:ns1="urn:uGlobalSOAPTypes"/> 
    <ns2:GetVersion soapenv:encodingStyle="
    <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="
http://schemas.xmlsoaporg/soap/encoding/" xsi:type="ns3:TSecurity" 
        <UserName xsi:type="xsd:string">VGVzdFVzZXJ=</UserName> 
        <Password xsi:type="xsd:string">VGVzdFBhc3N3b3Jk</Password> 

View raw message