• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

random xmlns attribute order causing unexpected XML tag exception

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am using Jdeveloper 11g to develop web service proxy using jAXWS approach.When i try to access the method using the stadalone java class, i get the following error
com.sun.xml.ws.streaming.XMLStreamReaderException: unexpected XML tag. expected: {http://peoplesoft.com/KCM_CASE_SOLN_CI}Get__CompIntfc__KCM_CASE_SOLN_CIResponse but found: {http://schemas.xmlsoap.org/ws/2002/xx/secext}Get__CompIntfc__KCM_CASE_SOLN_CIResponse
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.verifyTag(XMLStreamReaderUtil.java:214)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.verifyTag(XMLStreamReaderUtil.java:222)
at com.sun.xml.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:531)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:127)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:95)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
at $Proxy30.getCompIntfcKCMCASESOLNCI(Unknown Source)
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 weblogic.wsee.jaxws.spi.ClientInstance$ClientInstanceInvocationHandler.invoke(ClientInstance.java:363)
at $Proxy31.getCompIntfcKCMCASESOLNCI(Unknown Source)
at project1.proxy.KCM_CASE_SOLN_CISoapClient.main(KCM_CASE_SOLN_CISoapClient.java:51)

I checked the webservice using SOAP UI and its working fine.
I added soap handler to my java class and it shows the entire response from the webservice.
So i think its failing while trying to write the response to the java stub.
earlier working with a different webservice and integrating that webservice in to a JSF application, iwas getting the same error , i could resolve that by changing some mapping while creating the proxy.
This time i followed all the correct steps yet it is failing as a standlone java class let alone jsf application.
Any help will be appreciated.
Thank you in advance

regards
ash



 
ashvini tharval
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have noticed that the problem appears to be becoz of xmlns.
The webservice request message that is generated when the code is called creates an xml node inside the SOAP:Body with 2 xmlns attributes. It seems to add the xmlms attributes to the request message in random order. One order works and one causes an XMLStreamException when parsing the response.

The SOAP request which is been sent currently which causes error
S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/xx/secext" xmlns:ns2="http://peoplesoft.com/KCM_CASE_SOLN_CI">
<UsernameToken>
<Username></Username>
<Password></Password>....etc
The response i get is
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body><Get__CompIntfc__KCM_CASE_SOLN_CIResponse xmlns="http://schemas.xmlsoap.org/ws/2002/xx/secext">
As a result i get the exeception
com.sun.xml.ws.streaming.XMLStreamReaderException: unexpected XML tag. expected: {http://peoplesoft.com/KCM_CASE_SOLN_CI}Get__CompIntfc__KCM_CASE_SOLN_CIResponse but found: {http://schemas.xmlsoap.org/ws/2002/xx/secext}Get__CompIntfc__KCM_CASE_SOLN_CIResponse

While the other webservice which i am using , the request generated is
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header><ns2:Security xmlns="http://peoplesoft.com/KCM_WEB_CASE_CI" xmlns:ns2="http://schemas.xmlsoap.org/ws/2002/xx/secext">
<ns2:UsernameToken> <ns2:Username></ns2:Username>
<ns2:Password></ns2:Password>
</ns2:UsernameToken></ns2:Security></S:Heade>..

Respone i get is
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/><S:Body>
<Get__CompIntfc__KCM_WEB_CASE_CIResponse xmlns="http://peoplesoft.com/KCM_WEB_CASE_CI">
I dont know how can i handle this issue, something needs to be tweaked regarding the way these XMLNS attributes are assigned in the request.
Can any one please suggest what am i suppose to do??
Thanks
ash


 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. The one service that works has the Security tag qualified by its namespace ns2, and the default namespace is pointing to KCM_WEB_CASE_CI:

<ns2:Security xmlns="http://peoplesoft.com/KCM_WEB_CASE_CI" xmlns:ns2="http://schemas.xmlsoap.org/ws/2002/xx/secext">

And the one that you are having trouble with is:

<Security xmlns="http://schemas.xmlsoap.org/ws/2002/xx/secext" xmlns:ns2="http://peoplesoft.com/KCM_CASE_SOLN_CI">

Your request does look ok on the face of it, though the namespace prefixes are switched. A few things:

1. The request generated by your Java client - does the exact same request also work in SOAP UI? If yes, then the problem may be with the request XML. So please post your complete request (just the namespaces and tags).
2. Can you modify your client to a) add namespace ns2 (could be any string, not just ns2) pointing to secext, and b) prefix the Security, UsernameToken, Username and Password tags with ns2? And add the default namespace as KCM_WEB_CASE_CI. If you have a SOAPElement, you can use addNamespaceDeclaration(prefix, uri) and addChildElement(name, prefix) to do this. Basically, make it look like the request that works.

One guess: It is possible (though unlikely) that the web service itself might be hardcoded to take the default namespace (secext) from the request and assign it as the default namespace in the response (which should be KCM_WEB_CASE_CI, not secext).

Best of luck!
 
ashvini tharval
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srini,
Thank you for the response.
The request going from my application is as follows
S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Header><Security xmlns="http://schemas.xmlsoap.org/ws/2002/xx/secext" xmlns:ns2="http://peoplesoft.com/KCM_CASE_SOLN_CI">
<UsernameToken><Username></Username>
<Password></Password></UsernameToken></Security></S:Header>
<S:Body><ns2:Get__CompIntfc__KCM_CASE_SOLN_CI xmlns="http://schemas.xmlsoap.org/ws/2002/xx/secext" xmlns:ns2="http://peoplesoft.com/KCM_CASE_SOLN_CI">
<ns2:SETID>ABCD</ns2:SETID>
<ns2:SOLUTION_ID>1234</ns2:SOLUTION_ID>
</ns2:Get__CompIntfc__KCM_CASE_SOLN_CI></S:Body></S:Envelope>

Following are the answers to your questions
1> The request generated by Java client works in the SOAP UI. Even through the java client, i can see the response coming back, but the problem appears when the java client tries to parse the request and assign it to the correct java object, that is when it gives a stream reader exception coz it cannot find the element name within that namespace. i have tried altering the stubs but it does not work that way.


2>I did try to play with the security tag, i tried changing the prefix for the security tag, but it did not work.
I noticed the same randomness in case of <soap:body> tag and was tryiing to fix that, but everytime i remove the attribute xmlns and add a new xmlns with "http://peoplesoft.com/KCM_CASE_SOLN_CI", still in the request formed later it shows the default namespace to be http://schemas.xmlsoap.org/ws/2002/xx/secext, so i dont understand what is that i am doing wrongly.

3> I will try generating the stubs using a different ide and check what request it generates and if it works.

Thanks
Ashvini
 
ashvini tharval
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srini,

I have been able to modify the request in teh way it works using different methods in soap handler.
Basically i removed the namespace for "http://schemas.xmlsoap.org/ws/2002/xx/secext" from the body tag and now i am no longer getting that error and the jav client is able to map the response correctly.
But i still think this is more like a work around and would need something else to be fixed in order to use it further.
Any idea if i can tweak the generated stubs to take the namespace in that order??
Also the strange thing is that it generates the request correctly for the other webservice, i had generated stubs for both of them in the exact same way yet why would it show this discrepancy??

Thanks
Ashvini
 
R Srini
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ashvini. I don't know what else I can add. It is strange behaviour. If this were in Axis or Glassfish or Metro, I could have asked you for steps to reproduce this and then tried it out. But JDeveloper I have no experience with. Sorry. Having said that, this Oracle documentation explains how to create a web service client in JDeveloper 11g. I am pretty sure you must have come across this technique, though.
 
reply
    Bookmark Topic Watch Topic
  • New Topic