-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ok, the first advice is *never* use impl classes inside Axiom. Always
use the factories. The reason is we have multiple implementations of them.

To correct your problem, the easiest way is to create an OMElement
rather than a SOAPHeaderBlock and call serviceClient.addHeader(OMElement).

The second option is to use the created SOAP12Factory to create
SOAPHeaderBlock.
use soapFactory.createSOAPHeaderBlock(...)

HTH.
Chinthaka

Daniel Herbison wrote:
> I'm trying to add the SOAP header, described in comment in code below, to a
> RPC call to a service.  First of all I really do not know if the code to
> create the header is correct, i think it is in the ball park(?)  But I get a
> run time error of:
> 
> Exception in thread "main" java.lang.ClassCastException:
> org.apache.axiom.om.impl.OMNamespaceImpl
>         at
> org.apache.axiom.soap.impl.dom.SOAPHeaderBlockImpl.<init>(SOAPHeaderBlockImpl.java:54)
>         at
> org.apache.axiom.soap.impl.dom.soap12.SOAP12HeaderBlockImpl.<init>(SOAP12HeaderBlockImpl.java:45)
>         at rpcAxSys.main(Unknown Source)
> 
> the line causing the run time error is marked below, why is this doing this? 
> Also, is the header creation correct?
> 
> code------------------
> RPCServiceClient serviceClient = new RPCServiceClient();
> Options options = serviceClient.getOptions();
> EndpointReference targetEPR = new
> EndpointReference("https://xyz/Authorize/Service.asmx";);
> options.setTo(targetEPR);
> 
> /* header build
>  <soap:Header>
>   <BasicCredentials xmlns="beta">
>    <serviceId>string1</serviceId>    
>    <serviceKey>string2</serviceKey>  
>   </BasicCredentials>
>  </soap:Header>
>  */
> OMFactory fac = OMAbstractFactory.getOMFactory();
> OMNamespace omNs = fac.createOMNamespace("beta", "xmlns"); 
> 
> SOAPFactory soapFactory = new SOAP12Factory(); 
> SOAPHeaderBlock soapHeaderBlock = new
> SOAP12HeaderBlockImpl("Security",omNs,soapFactory); 
> soapHeaderBlock.setMustUnderstand(true); 
> 
> OMElement basicCredentials = fac.createOMElement("BasicCredentials", omNs); 
> 
> OMElement serviceId = fac.createOMElement("serviceId", omNs); 
> OMText serviceIdText = fac.createOMText(serviceId, agentID);
> serviceId.addChild(serviceIdText); 
> 
> OMElement serviceKey = fac.createOMElement("serviceKey", omNs); 
> OMText serviceKeyText = fac.createOMText(serviceKey, agentToken);
> serviceKey.addChild(serviceKeyText); 
> 
> basicCredentials.addChild(serviceId); 
> basicCredentials.addChild(serviceKey); 
> 
> soapHeaderBlock.addChild(basicCredentials); 
> 
> serviceClient.addHeader(soapHeaderBlock); 
> // end header build
> 
> QName opSetClaim = new QName("beta", "GetClaim" );
> 
> Object[] opSetParams = new Object[] { agentID, agentToken, requestor };
> Class[] returnTypes = new Class[] { Object.class };
> 
> Object[] response = serviceClient.invokeBlocking(opSetClaim, opSetParams,
> returnTypes);
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGQ/jSjON2uBzUhh8RAqVZAKC0exk4tKs9zIALPgI65NYyo+AbxQCePUqQ
xt15TCLceO7fDJe517267k8=
=duG+
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to