axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michele Mazzucco <Michele.Mazzu...@ncl.ac.uk>
Subject Re: Creating Axis2 SOAP Header
Date Thu, 10 May 2007 13:47:08 GMT
Daniel,

could you please enable the debug  of javac (it is enabled by default,
remove the -g:none option) and tell us which line causes the problem?

Michele

On Thu, 2007-05-10 at 05:28 -0700, Daniel Herbison wrote:
> Thank you for your replies!
> I tried the code below and still get a runtime casting error.
> 
> Exception in thread "main" java.lang.ClassCastException:
> org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory
>         at rpcAxSys.header2(Unknown Source)
>         at rpcAxSys.main(Unknown Source)
> 
> SOAP12Factory factory = (SOAP12Factory)
> OMAbstractFactory.getSOAP12Factory();
> OMNamespace omNs = factory.createOMNamespace("beta.va.nortel.com", "xmlns"); 
> 
> SOAPHeader header = factory.createSOAPHeader();
> 
> SOAPHeaderBlock block = factory.createSOAPHeaderBlock("BasicCredentials",
> omNs);
> 
> OMElement serviceId = factory.createOMElement("serviceId", omNs); 
> OMText serviceIdText = factory.createOMText(serviceId, agentID);
> serviceId.addChild(serviceIdText); 
> 
> OMElement serviceKey = factory.createOMElement("serviceKey", omNs); 
> OMText serviceKeyText = factory.createOMText(serviceKey, agentToken);
> serviceKey.addChild(serviceKeyText); 
> 
> block.addChild(serviceId);
> block.addChild(serviceKey);
> 
> header.addChild(block);
> 
> 
> Amila Suriarachchi wrote:
> > 
> > I am not sure about your problem.
> > but add this code to specifically set the soap12 for service client.
> > 
> > clientOptions = new Options();
> > clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI
> > );
> > serviceClient.setOptions(clientOptions);
> > 
> > On 5/10/07, Michele Mazzucco <Michele.Mazzucco@ncl.ac.uk> wrote:
> >>
> >> Daniel,
> >>
> >> I think the way you create the SOAPHeaderBlock is not correct. Can
> >> you try this way please?
> >>
> >> SOAP12Factory factory = (SOAP12Factory)
> >> OMAbstractFactory.getSOAP12Factory();
> >> OMNamespace omNs = factory.createOMNamespace(
> >>                         "http://...",
> >>                         "..."
> >>                 );
> >>
> >> SOAPEnvelope env = factory.createSOAPEnvelope();
> >> SOAPHeader header = factory.createSOAPHeader();
> >> SOAPHeaderBlock block = factory.createSOAPHeaderBlock(
> >>         SOAPHeaderConstants.ELEM_QOSP_HEADER_BLOCK, omNs);
> >> OMElement type = factory.createOMElement(
> >>                 SOAPHeaderConstants.ELEM_MESSAGE_TYPE, omNs);
> >>
> >> type.setText(MessageType.UPLOAD.value());
> >> block.addChild(type);
> >> header.addChild(block);
> >>
> >> SOAPBody body = factory.createSOAPBody();
> >> OMElement method = factory.createOMElement(SOAPUtils.UPLOAD_SERVICE,
> >> omNs);
> >>
> >> OMElement name = factory.createOMElement(
> >>         SOAPUtils.UPLOAD_SERVICE_FILE_NAME, omNs);
> >> name.setText(this.fileName);
> >>
> >> method.addChild(name);
> >> body.addChild(method);
> >> env.addChild(header);
> >> env.addChild(body);
> >>
> >>
> >> Michele
> >>
> >>
> >>
> >>
> >> On 9 May 2007, at 22:26, 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);
> >> >
> >> > --
> >> > View this message in context: http://www.nabble.com/Creating-Axis2-
> >> > SOAP-Header-tf3718396.html#a10403132
> >> > Sent from the Axis - User mailing list archive at Nabble.com.
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >> For additional commands, e-mail: axis-user-help@ws.apache.org
> >>
> >>
> > 
> > 
> > -- 
> > Amila Suriarachchi,
> > WSO2 Inc.
> > 
> > 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message