Hi, On Sun, May 23, 2010 at 8:52 PM, Andreas Veithen <[email protected]>wrote:
> On Sun, May 23, 2010 at 16:42, Hiranya Jayathilaka <[email protected]> > wrote: > > Hi Devs, > > I'm trying to invoke a simple web service over UDP. I have properly > > configured and exposed my service (SimpleStockQuoteService in Synapse) > over > > UDP transport and I use the following client to invoke the service: > > public static void main(String[] args) throws Exception { > > String request = > > "<m0:getQuote xmlns:m0=\"http://services.samples\">" + > > "<m0:request>" + > > "<m0:symbol>IBM</m0:symbol>" + > > "</m0:request>" + > > "</m0:getQuote>"; > > ConfigurationContext cfgCtx = > > > > ConfigurationContextFactory.createConfigurationContextFromFileSystem( > > CLIENT_HOME + "/client_repo", > > CLIENT_HOME + "/client_repo/conf/axis2.xml"); > > ServiceClient client = new ServiceClient(cfgCtx, null); > > client.engageModule("addressing"); > > Options options = new Options(); > > options.setTo(new > > > EndpointReference("udp://localhost:9999/services/SimpleStockQuoteService?contentType=text/xml")); > > options.setAction("urn:getQuote"); > > client.setOptions(options); > > OMElement res = > client.sendReceive(AXIOMUtil.stringToOM(request)); > > > > System.out.println(res); // > *************************************** > > client.cleanup(); > > System.out.println("VALUE: " + parseStandardQuoteResponse(res)); > > } > > public static String parseStandardQuoteResponse(OMElement result) > throws > > Exception { > > AXIOMXPath xPath = new AXIOMXPath("//ns:last"); > > xPath.addNamespace("ns","http://services.samples/xsd"); > > OMElement last = (OMElement) xPath.selectSingleNode(result); > > if (last != null) { > > return last.getText(); > > } else { > > throw new Exception("Unexpected response : " + result); > > } > > } > > > > I can see the client is receiving the correct response. The print > statement > > (marked with ********) gets executed and it prints the response payload > as > > expected: > > <ns:getQuoteResponse xmlns:ns="http://services.samples"><ns:return > > xmlns:ax21="http://services.samples/xsd" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > > xsi:type="ax21:GetQuoteResponse"><ax21:change>-2.3994058702324095</ax21:change><ax21:earnings>-9.185768238192317</ax21:earnings><ax21:high>-158.13498398871758</ax21:high><ax21:last>158.5652017864806</ax21:last><ax21:lastTradeTimestamp>Sun > > May 23 20:09:13 IST > > > 2010</ax21:lastTradeTimestamp><ax21:low>-157.20036313216417</ax21:low><ax21:marketCap>5.393598252226892E7</ax21:marketCap><ax21:name>IBM > > > Company</ax21:name><ax21:open>165.6030739863106</ax21:open><ax21:peRatio>24.08910588357344</ax21:peRatio><ax21:percentageChange>1.5441539764455583</ax21:percentageChange><ax21:prevClose>-155.38643858273318</ax21:prevClose><ax21:symbol>IBM</ax21:symbol><ax21:volume>18163</ax21:volume></ns:return></ns:getQuoteResponse> > > But then the parseStandardQuoteResponse method fails with the following > > exception: > > Exception in thread "main" org.apache.axiom.om.OMException: > > com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character (NULL, > > unicode 0) encountered: not valid in any content > > at [row,col {unknown-source}]: [1,1234] > > at > > > org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:267) > > at > > > org.apache.axiom.om.impl.llom.OMDocumentImpl.buildNext(OMDocumentImpl.java:130) > > at > > > org.apache.axiom.om.impl.llom.OMNodeImpl.getNextOMSibling(OMNodeImpl.java:122) > > at > > > org.apache.axiom.om.impl.llom.OMElementImpl.getNextOMSibling(OMElementImpl.java:344) > > at > > > org.apache.axiom.om.impl.traverse.OMChildrenIterator.next(OMChildrenIterator.java:102) > > at > > > org.jaxen.util.DescendantAxisIterator.next(DescendantAxisIterator.java:127) > > at org.jaxen.expr.DefaultStep.evaluate(DefaultStep.java:154) > > at > org.jaxen.expr.DefaultLocationPath.evaluate(DefaultLocationPath.java:140) > > at > > > org.jaxen.expr.DefaultAbsoluteLocationPath.evaluate(DefaultAbsoluteLocationPath.java:113) > > at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:102) > > at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:674) > > at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:213) > > at org.jaxen.BaseXPath.selectSingleNode(BaseXPath.java:234) > > at > > > org.wso2.test.tools.Axis2UDPClient.parseStandardQuoteResponse(Axis2UDPClient.java:63) > > at org.wso2.test.tools.Axis2UDPClient.main(Axis2UDPClient.java:56) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > at > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) > > Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal > character > > (NULL, unicode 0) encountered: not valid in any content > > at [row,col {unknown-source}]: [1,1234] > > at > > > com.ctc.wstx.sr.StreamScanner.constructNullCharException(StreamScanner.java:615) > > at > com.ctc.wstx.sr.StreamScanner.throwInvalidSpace(StreamScanner.java:644) > > at > com.ctc.wstx.sr.StreamScanner.throwInvalidSpace(StreamScanner.java:635) > > at > > > com.ctc.wstx.sr.BasicStreamReader.readSpacePrimary(BasicStreamReader.java:4914) > > at > > > com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2003) > > at > > > com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2647) > > at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1019) > > at > > > org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:221) > > at > > > org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:33) > > at > > > org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:221) > > at > > > javax.xml.stream.util.StreamReaderDelegate.next(StreamReaderDelegate.java:60) > > at > > > org.apache.axiom.om.impl.builder.SafeXMLStreamReader.next(SafeXMLStreamReader.java:221) > > at > > > org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:636) > > at > > > org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:188) > > ... 19 more > > The same exact code works fine with the HTTP transport. So I guess this > has > > something to do with the UDP transport. Any ideas? > > Broken code introduced in WSCOMMONS-511. I will see if I can apply the > testkit to the UDP transport so that we can do some quality checks. > Thanks for looking into this Andreas. I'll also run some debug sessions and try to pin down the problem. Another interesting observation: If I clone the response OMElement and pass that to the helper method, it will work fine. Or if I get a string out of the response OMElement and convert that back to an OMElement things will still work just fine. Thanks, Hiranya > > Thanks, > > Hiranya > > -- > > Hiranya Jayathilaka > > Senior Software Engineer; > > WSO2 Inc.; http://wso2.org > > E-mail: [email protected]; Mobile: +94 77 633 3491 > > Blog: http://techfeast-hiranya.blogspot.com > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Hiranya Jayathilaka Senior Software Engineer; WSO2 Inc.; http://wso2.org E-mail: [email protected]; Mobile: +94 77 633 3491 Blog: http://techfeast-hiranya.blogspot.com
