Netbeans and .NET web services

谁说胖子不能爱 提交于 2020-01-24 20:06:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!