How to call the webService interface according to the wsdl offline file

       

       When the client provides a webService interface document, the document contains the wsdl offline file, how should we call the webService interface

 

mouth. Now there are fewer interface calls, write a blog to record it, I hope that the next time you use it, you can quickly connect to the interface without being blind, attached

 

The service.wsdl file is stored in the demo of the file, and the client can be generated according to the wsdl. The configuration is the intranet address, which cannot be accessed.

 

Same way.

 

1. Copy the wsdl file to the eclipse project. Support java project and web project

 

2. Right-click web Service---->Generater Client on the wsdl file with the mouse, the latter are all defaults, and finally click finish.

 

3. Write the main method for testing.

 

public static void main(String[] args) throws RemoteException, ServiceException  {

 

     ServiceSoap_Service client = new ServiceSoap_ServiceLocator();

 

     NGCCServiceRequest requestPara = new NGCCServiceRequest();

 

     NGCCServiceRequestType requestType = new NGCCServiceRequestType();

 

     //This place is to set relevant parameters, the specific parameters to be set are determined according to the client generated by wsdl

 

     requestType.setService("CallSCEUser");

 

     requestType.setClientid("1000");

 

     requestType.setPasswd("65EFAB9E62A568F16784A02E7D1EB4A6");

 

     requestType.setFlowno("20110704103015000001");

 

     requestType.setContent(readRenWuFile("13851619632"));

 

     requestPara.setNGCCServiceReq(requestType);

 

     NGCCServiceResponse nGCCServiceResponse =

   

    client.getServiceSoap().NGCCServices(requestPara);

   

    //Request to get the interface of remote call

     NGCCServiceResponseType type = nGCCServiceResponse.getNGCCServiceRes();

   

     System.out.println(type.getFlowno());

}

 

Note: After the wsdl file provided by the customer, if the client is directly generated, the access path in the wsdl file needs to be modified and viewed. If it is generated directly without modification, it cannot be accessed. If the client is generated first, you need to modify the value of the parameter ServiceSoap_address in ServiceSoap_ServiceLocator.java. Just change her to the actual wsdl access path.

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326915351&siteId=291194637