The webservice provided by the other side is written in C #, and I can use this scheme for Java or C # (pro-Test) WebService. The steps are as follows:
1, create a common Java project, on the project right-new–other–web service Client–next, enter the WebService address in the box, for example: http://10.10.10.60:7000/srv_ WAIPAIITEM/WS/WP?WSDL (after the address is entered, you need to wait two seconds for next to click)
2, enter the correct WebService address, the way after the completion of the project will be under the SRC production of similar directory files:
The shortest class name is usually the name of the file you need.
3. The jar package that needs to be added is as follows: Jar package (free points): http://download.csdn.net/detail/zl544434558/8561227
4. The main method of the test code:
import org. Apache. CXF. Jaxws. Jaxwsproxyfactorybean;Importcom. ciming. Waipaiitem. WS. Waipairecordws;public class Testwebserviceclient {public static void main (string[] args) throws Exception {Jaxwsproxyfactorybean fact Ory = new Jaxwsproxyfactorybean ();Register WebService Interface Factory. Setserviceclass(Waipairecordws. Class);Set WebService address String url ="HTTP://10.10.10.61:7001/SRV_WAIPAIITEM/WS/WP?WSDL";Factory. Setaddress(URL);Waipairecordws record = (WAIPAIRECORDWS) factory. Create();Interface provides a method named Getdeliverysinglestring jsonstring = Record. Getdeliverysingle("ADK","Adkpwd","003300114112150914","Hz2_2");System. out. println(jsonstring);System. out. println("Successful Execution");}}
But if you run directly you will report a similar error like this:
ExceptioninchThread"Main"Javax. XML. WS. Webserviceexception: Could not find wsdl:binding operation info for Web method getdeliverysingle. at org. Apache. CXF. Jaxws. Jaxwsclientproxy. Invoke(Jaxwsclientproxy. Java:123) atcom. Sun. Proxy. $Proxy 17. Getdeliverysingle(Unknown Source) atcom. Evan. WebService. Test. Testwebserviceclient. Main(testwebserviceclient. Java: +)
The solution to this error is to add @webservice annotations to the interface of the generated file. For example, this project only needs to add @webservice to the Waipairecordws interface.
Java has now been able to invoke the remote webservice normally. and is as convenient as calling local methods. The entire demo:http://download.csdn.net/detail/zl544434558/8561301 of the project
Java Call WebService interface complete source code