if instance declaration is

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";

then the declaration for xsi:type="ax21:GetQuoteResponse"

 

which assumes your type must be a qname (does this definition exist?) 
Here is example

http://www.ibm.com/developerworks/webservices/library/ws-soapmap1/#listing2

 

?
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.



 



Date: Sun, 23 May 2010 20:12:15 +0530
Subject: Error While Invoking Service Over UDP
From: hiranya...@gmail.com
To: java-dev@axis.apache.org


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?


Thanks,
Hiranya    
-- 
Hiranya Jayathilaka
Senior Software Engineer;
WSO2 Inc.;  http://wso2.org
E-mail: hira...@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com
                                          
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4

Reply via email to