Hi, Code looks okay. The place you are getting 'element', check whether you are getting the complete SOAP envelope or only the 'Body' contents. That will depend on what you working with. You can check that with a println of 'element'. If it is the first element of the 'Body' that 'element' has, then consumerId.toString(); will throw a NullPointerException. if(consumerId != null) System.out.println(consumerId.getText());
If it is 'Body' contents, try changing the xpath to "/u:providerInfoRequest/u:consumerId". Send the stack trace if this does not work. Upul On 10/7/07, Anil John <[EMAIL PROTECTED]> wrote: > > I currently have the following SOAP request being sent to an Axis2 > service: > > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/ > " > xmlns:urn="urn:my:schema:messages:2007-01-01"> > <soapenv:Header/> > <soapenv:Body> > <urn:providerInfoRequest> > <urn:consumerId>SomeValue</urn:consumerId> > </urn:providerInfoRequest> > </soapenv:Body> > </soapenv:Envelope> > > On the service side, I am trying to parse out the value of "consumerId". I > am using the following code and am getting a SOAP fault: > > String xpathString = > "/s:Envelope/s:Body/u:providerInfoRequest/u:consumerId"; > AXIOMXPath xpathExpression = new AXIOMXPath(xpathString); > xpathExpression.addNamespace("u", "urn:my:schema:messages:2007-01-01"); > xpathExpression.addNamespace("s", > "http://schemas.xmlsoap.org/soap/envelope/"); > OMElement consumerId = (OMElement) > xpathExpression.selectSingleNode(element); > String idValue = consumerId.toString(); > > I am a newbie to using XPath with AXIOM and am more than likely doing > something wrong here.. Would appreciate some help in troubleshooting. > > Regards, > > - Anil > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
