aspose file tools*
The moose likes Web Services and the fly likes Namespace Prefix Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Namespace Prefix Problem" Watch "Namespace Prefix Problem" New topic
Forums: Web Services XML and Related Technologies
Author

Namespace Prefix Problem

Florian Schaetz
Greenhorn

Joined: Oct 14, 2009
Posts: 13
Hello,

I've got a WebService here, implemented in Java, WSDL and JAXWS classes generated with wsgen, works fine for most people. Only recently, someone tried to access it via C# and found a problem which I have unfortunately been able to reproduce in C#, but quite honestly, I have no clue if the problem is C# or my Webservice...

The XML C# produces looks like this...



...which leads to the problem, that the vendor (=arg0) is "null" in the WebService class, it seems it doesn't get deserialized properly (but no warning/error message in my server log, either). I'm using geronimo 2.2, btw.

It should look like this...



Interesting enough, the first xml also works, if the id attribute isn't there (but of course, the code requires it and changing the WSDL to element instead of attribute is hard, because many people already use this version of the WSDL). As I really have not much experience with XML namespaces, I would like to know, if the later xml is, at least theoretically, acceptable for a WebService? SoapUI, for example, has no trouble creating a client (it puts the x-namespace declaration into the envelope, but otherwise it looks the same. So is the problem C# here? Or did I somehow create a non-standard WSDL?

The WSDL looks like...



and the referenced schema like this...



Has anyone at least an idea if the problem is the Java end or the C# end?

Regards,

Flo
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 539
    
    3
I would like to know, if the later xml is, at least theoretically, acceptable for a WebService?

I would say the "latter" (produced by java-client? or soapui?) and the "former" (produced by c#-client) are equivalent. They should both acceptable or both rejectable for the same web service.

Has anyone at least an idea if the problem is the Java end or the C# end?

For the reason of the above, the problem is not of c# end because java end and c# end produce the same thing. The problem is from where, I have no idea. But your discourse on wsdl/service-client/acceptability is not consistent. Maybe your reading (to produce a brief outline) on the actual wsdl is incorrect.

Interesting enough, the first xml also works, if the id attribute isn't there...

This is also a clue that your summary on the wsdl and its types is suspicious. By what shown, id shouldn't be there at all. There should be at least an attribute called extId. Furthermore, arg0 shouldn't be an empty element. It should at least contain an element name1. See, so much inconsistent that makes me wonder why the soap generated by soapui should work at all.
Florian Schaetz
Greenhorn

Joined: Oct 14, 2009
Posts: 13
Oh, you are right, I'm sorry, when trying to simplify it (because I thought it's easier to know what "id" is instead of "extId") I added some mistakes that aren't in the original code, so the original xml contains "extId" and "name1".

Interesting enough, you CAN omit the extId (and name1). While the xml is technically not valid anymore, it still gets parsed correctly (with extId = null) by the WebService. Schema validation doesn't seem to take place and JAXB/P is quite generous there (ignoring fields it doesn't know, allowing required fields missing), so this isn't part of the problem.

But if both parts are valid, then why does the Java WebService only parse one correctly, while parsing arg0/vendor as null in the other case? (The latter was created by the client classes created with wsimport tool, SOAP-UI creates something similar, only putting the declaration of namespace "x" (naming it "imp") into the Envelope itself, which works fine).

Another detail: The "xmlns="" " thing in arg0 is also completely without any effect, I can omit it and the code still produces the same result (working, if the prefix is there in the addVendor or not working, if it isn't). Seems to have no effect at all.
 
Consider Paul's rocket mass heater.
 
subject: Namespace Prefix Problem