Meaningless Drivel is fun!*
The moose likes XML and Related Technologies and the fly likes Excpetion deserialization error while creating XML for sending via web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Excpetion deserialization error while creating XML for sending via web service" Watch "Excpetion deserialization error while creating XML for sending via web service" New topic
Author

Excpetion deserialization error while creating XML for sending via web service

Veljko Cankovic
Greenhorn

Joined: Dec 27, 2011
Posts: 12
I need help for this.

My WSDL request is in this format:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://response.micromuse.com/types">
<soapenv:Header/>
<soapenv:Body>
<typ:runPolicy>
<WSListenerId_1>
<clientId>?</clientId>
<objectId>?</objectId>
</WSListenerId_1>
<String_2>?</String_2>
<!--Zero or more repetitions:-->
<arrayOfWSPolicyUserParameter_3>
<desc>?</desc>
<format>?</format>
<label>?</label>
<name>?</name>
<value>?</value>
</arrayOfWSPolicyUserParameter_3>
<boolean_4>?</boolean_4>
</typ:runPolicy>
</soapenv:Body>
</soapenv:Envelope>


So I created this using JDOM like many times before.
This is part of my code:
Element top = new Element("runPolicy",nsURI );
Document jDoc = new Document(top);
Element WSListenerId_1 = new Element("WSListenerId_1", nsURI);
top.addContent(WSListenerId_1);

etc. .......


But in log file I am getting this as an output:

<?xml version="1.0" encoding="UTF-8"?>^M
<runPolicy xmlns="http://response.micromuse.com/types">^M
<WSListenerId_1>^M
<clientId>tipadmin</clientId>^M
<objectId>0.044691184148206387</objectId>^M
</WSListenerId_1>^M
<String_2>TSRM_policy</String_2>^M
<arrayOfWSPolicyUserParameter_3>^M
<desc>TICKETID</desc>^M
<format>STRING</format>^M
<label>TICKETID</label>^M
<name>TICKETID</name>^M
<value>100009</value>^M
</arrayOfWSPolicyUserParameter_3>^M
<boolean_4>1</boolean_4>^M
</runPolicy


I do not know what is this ^M in XML. Maybe this is causing the problem below?

Exception:
JAXRPC.TIE.01: caught exception while handling request: deserialization error: unexpected XML reader state. expected: END but found: START: {http://response.micromuse.com/types}WSListenerId_1


Thanks for help
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The ^M is how carriage-return characters are represented in Unix-like systems. The normal line ending for XML documents is line-feed only, without carriage-returns, but the parser should normalize the extra carriage-return characters away. So that isn't the problem.

My guess is that in your original example, the <WSListenerId_1> element is not in any namespace. But in your log file, the <WSListenerId_1> element is in the "http://response.micromuse.com/types" namespace. And your code fragment confirms that, it does create it in that namespace. Apparently the parser isn't expecting to find a <WSListenerId_1> element from the "http://response.micromuse.com/types" namespace, so it throws that exception.
Veljko Cankovic
Greenhorn

Joined: Dec 27, 2011
Posts: 12
Paul thanks for answer.

Yes for every elemnt I defined and his namespace.
So you want to say for <WSListenerId_1> I dont have to define namespace when creating elemnt?
I supose that is also and for his children.
What about rest of the elements: <String_2>, arrayOfWSPolicyUserParameter_3 and its children, and <boolean_4>- do they have to have defined namespace or not? I had never made elemnts without namespace in some my previous classes so its a little confusing for me
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Veljko Cankovic wrote:So you want to say for <WSListenerId_1> I dont have to define namespace when creating elemnt?


Based on your first example, yes. Notice that the <typ:runPolicy> element is in a namespace, but since it isn't the default namespace, its child elements don't inherit the namespace declaration. Therefore the children aren't in any namespace.

I supose that is also and for his children.
What about rest of the elements: <String_2>, arrayOfWSPolicyUserParameter_3 and its children, and <boolean_4>- do they have to have defined namespace or not? I had never made elemnts without namespace in some my previous classes so its a little confusing for me


Based on your first example, that's right, all of the elements whose name doesn't have the "typ:" prefix aren't in any namespace.

In the file you generated, the <runPolicy> element is in the correct namespace, but it's the default namespace (so there's no prefix on the element name). In this case the children and descendants of that element are all in that same namespace, because default namespace declarations are inherited by children from their parents. Apparently you want them to be in no namespace, so generate them that way.

I haven't looked at JDOM for a long time but my guess is you should do this:



The documentation should explain how to use or not use namespaces, though, if you want to check.
 
wood burning stoves
 
subject: Excpetion deserialization error while creating XML for sending via web service
 
Similar Threads
SOAP body - multiply choice parts
soap fault return empty <detail> element.
altering the xml output for axis2 soap response
RPC/Literal vs Document/Literal
wsdl stubs adding own namespace around soap message