axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tony.q.wed...@gsk.com
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.

Tony



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 ----- 
From: tony.q.weddle@gsk.com 
To: axis-user@ws.apache.org 
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. 

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="#id0" 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> 
 

Mime
View raw message