问题
I'm not an experienced java developer so any comment will be welcomed ...
I've written a web service using c# and I wanted to consume this service from java - used Netbeans for this task.
All methods works well beside one: the method expecting a type called BusinessDataField2 - this type contains 2 fields: name(string) and value(object)
Those fields are filled using get,set methods - this works easily at the .NET environment.
However ...
I can see that Java requires different parameters for the get and set methods - the parameter is :
JAXBElement JAXBElement
The question is: how do I instantiate this object? I tried many different ways but nothing worked...
Thanks, ofer
回答1:
You should not use the "object" type. It could be any actual type, but you're not telling the Java side what to expect. The best it can do, then, is process the actual XML of the value.
Consider: the object could be an int, or it could be some complex structure. How would the Java side know what to do with it? The Java side wouldn't even have a proxy classs for the complex structure, because you never told it that you could ever return the complex structure.
回答2:
I'd recommend using the CXF web service framework to consume your web service. It can look at your wsdl file and generate java objects that correspond to your .net objects.
They have a HOWTO on their site as well.
来源:https://stackoverflow.com/questions/590514/netbeans-and-net-web-services