java call interface C # webService released

java call interface C # webService released

java call C # webService There are many ways I am here only introduces a

Necessary to introduce the axis of the jar package maven axis coordinates as follows

<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>

Also you can go to this address search and then copy the coordinates input to    https://mvnrepository.com/

 

Here is the call Liezi Code:

1    // interface address 
2          String oaurl = Preferences.getInstance () getOAURL ();.
 . 3          String Result = null ;
 . 4          the try {
 . 5              // namespace I Here is an example of code just write address namespace (specific address can wsdl file Viewer or ask the provider to obtain the interface)) 
6              String SOAPAction = "http://localhost.org/" ;
 7              service service = new new service ();
 8              // create call object, call object is used to invoke the service 
9              call call = (Call) Service.createCall ();
 10              // set webServiced of the URL 
. 11             call.setTargetEndpointAddress (oaurl);
 12 is              // Set the name of the calling method 
13 is              call.setOperationName ( new new the QName (SOAPAction, "getJSON")); // Set the name of the method to invoke
 14              // set the request parameter (str is the interface parametric, specific interface to view your call) 
15              call.addParameter ( new new QName (SOAPAction, "str" ),
 16                      org.apache.axis.encoding.XMLType.XSD_STRING,
 17                      javax.xml.rpc.ParameterMode.IN);
 18 is  
. 19             / ** 
20              * may be arranged such request parameters, specific parameters into the mode selected according to the interface
 21 is              * call.addParameter (the QName new new (SOAPAction, "the userName"),
22             *                     org.apache.axis.encoding.XMLType.XSD_STRING,
23             *                     javax.xml.rpc.ParameterMode.IN);
24             * call.addParameter(new QName(soapaction , "phone"),
25             *                     org.apache.axis.encoding.XMLType.XSD_STRING,
26             *                     javax.xml.rpc.ParameterMode.IN);
27             * */
28             //设置返回结果类型
29             call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
30             //call.setReturnType(new QName(soapaction, "GetJson"), String.class);
31             call.setUseSOAPAction(true);
32             call.setSOAPActionURI(soapaction + "GetJson");
33 
34             Map<String, Object> params = new HashMap<>();
35 
36             List<String> list = new ArrayList<>();
37 
38             String[] address = new String[]{"http://www.baidu.com/1.jpg"};
39             String[] fileName = new String[]{"附件1"};
40             String dateStr = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
41             String[] fileDate = new String[]{dateStr};
42 
43             Collections.addAll(list , "2019-10-14 09:48:35.930", "slbh", "101000001", "hm", "20", "ch", "cnxh", "bw", "q6q", "gyh",
44                     "kj", "lxr", "dh", "符合申请");
45             params.put("flowname", "符合申请");
46             params.put("username", "pinlin");
47             params.put("data" , list);
48             params.put("attach_count", "1");
4960              * If a plurality of the above setting parameters. Parameter passing order to set the order to be consistent
 61              * 
             
 
                 */
62             result = (String) call.invoke(new Object[]{strs});
63             System.out.println("result = " + result);
64         } catch (Exception e) {
65             e.printStackTrace();
66             log.error(e.toString());
67         }

How to view wsdl get through the interface addresses here for the weather forecast for the Liezi common interface, as follows

 http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl 

? Wsdl behind the interface address plus you can introduce here some basic information is as follows:

 

 

 

Access can also directly address those interfaces, follow these steps:

http://www.webxml.com.cn/WebServices/WeatherWebService.asmx 

 

 These methods can click on the name to enter the call there will be explained the way, as follows:

 

 

 

 

 

 

 Call released C # webservice of the API can also wsdl file directly to the client code calls, there are apache-cxf, which I have used, but the code generated by my call is not successful, I do not know if I am wrong operation, specific issues that I have in exploration.

It is limited reissue is my first blog post, a place where to write bad or wrong, also please a lot of guidance.

由于第一次写博客,排版有些不好还请谅解。

 

Guess you like

Origin www.cnblogs.com/zengpinlin/p/11951711.html