What about env.serialize(System.out)?, where env is a SOAPEnvelope object? Michele
On Thu, 2007-05-10 at 07:55 -0700, Daniel Herbison wrote: > I changed this: > > SOAPFactory factory = (SOAPFactory) OMAbstractFactory.getSOAP12Factory(); > > and got rid of the error but it is failing on the call with: > > Exception in thread "main" org.apache.axiom.soap.SOAPProcessingException: > Expecting an implementation of SOAP Envelope as the parent. But received > some other implementation > at > org.apache.axiom.soap.impl.llom.SOAPHeaderImpl.checkParent(SOAPHeaderImpl.java:369) > at > org.apache.axiom.soap.impl.llom.SOAPElement.setParent(SOAPElement.java:75) > at > org.apache.axiom.om.impl.llom.OMElementImpl.addChild(OMElementImpl.java:236) > at > org.apache.axiom.om.impl.llom.OMElementImpl.addChild(OMElementImpl.java:192) > at > org.apache.axis2.client.ServiceClient.addHeadersToEnvelope(ServiceClient.java:647) > at > org.apache.axis2.client.ServiceClient.fillSOAPEnvelope(ServiceClient.java:633) > at > org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:517) > at > org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:500) > at > org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:97) > at rpcAxSys.main(rpcAxSys.java:51) > > Is there a way to print the soap message out before calling invokeBlocking? > > Code excluding header code, same as before. > > rpcAxSys rpc = new rpcAxSys(args[0],args[1],args[2]); > EndpointReference targetEPR = new > EndpointReference("https://pcary571.corp.nortel.com/Authorize/Service.asmx"); > RPCServiceClient serviceClient = new RPCServiceClient(); > Options options = serviceClient.getOptions(); > options.setTo(targetEPR); > serviceClient.addHeader(rpc.header2()); // header2 has header generation > code below > QName opSetClaim = new QName("beta", "GetClaim" ); > Object[] opSetParams = new Object[] { rpc.agentID, rpc.agentToken, > rpc.requestor }; > Class[] returnTypes = new Class[] { Object.class }; > Object[] response = serviceClient.invokeBlocking(opSetClaim, opSetParams, > returnTypes); FAILING HERE > > > > > Michele Mazzucco-2 wrote: > > > > 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > >> >> > For additional commands, e-mail: [EMAIL PROTECTED] > >> >> > > >> >> > >> >> > >> >> --------------------------------------------------------------------- > >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> >> For additional commands, e-mail: [EMAIL PROTECTED] > >> >> > >> >> > >> > > >> > > >> > -- > >> > Amila Suriarachchi, > >> > WSO2 Inc. > >> > > >> > > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]