Quickest way to access a webservice with WSDL in Java

强颜欢笑 提交于 2019-12-22 08:17:59

问题


I need to access a webservice from Java. The service has a WSDL. Now how do I get to calling its operations?

  • I've already used wsimport on it, but that only generates XML objects for the operations/responses, nothing to actually call them.
  • I've looked at Spring-WS but it doesn't look like it's completely what I want (even though it might be part of the solution). The word "wsdl" doesn't appear in that page at all.

回答1:


wsimport does not only generate the Objects needed for communication with the service but also a service client. Create an instance of the class MSaleService and fetch the port with getMSaleServiceSoap(). That's it.

There might be some problems though. wsimport complained about

[WARNING] SOAP port "MSaleServiceSoap12": uses a non-standard SOAP 1.2 binding.
line 530 of http://vas.mikro-odeme.com/services/msaleservice.asmx?wsdl

but I don't know if this poses real problems.




回答2:


Here is a quick link I found

http://download.oracle.com/javaee/1.4/tutorial/doc/JAXRPC5.html

Basically, this type of calling is calling Dynamic Invocation where you would NOT need to know the WSDL apriori.




回答3:


If you use Eclipse, there's this wizard that let's you create what's called a new "Web Service Client" just by pointing at your wsdl file.

so if you have your wsdl in your project, then just click on "new" and choose the wizard.

it'll ask you for the wsdl file and some other info (you can choose your runtime -Axis, Axis2, CXF...).

i think this wizard is part of WTP (www.eclipse.org/webtools).

take a look:

http://tinyurl.com/5v56s5u

http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/WebServiceClient/WebServiceClient.html



来源:https://stackoverflow.com/questions/6280907/quickest-way-to-access-a-webservice-with-wsdl-in-java

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