Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Excpetion deserialization error while creating XML for sending via web service

 
Veljko Cankovic
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20719
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20719
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic