java开发webservice接口有几种方式

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java开发webservice接口有几种方式相关的知识,希望对你有一定的参考价值。

参考技术A

Support for Standards
JSR Support

    JAX-WS - Java API for XML-Based Web Services (JAX-WS) 2.0 - JSR-224
    Web Services Metadata for the Java Platform - JSR-181
    JAX-RS - The Java API for RESTful Web Services - JSR-311
    SAAJ - SOAP with Attachments API for Java (SAAJ) - JSR-67

WS-* and related Specifications Support

    Basic support: WS-I Basic Profile 1.1
    Quality of Service: WS-Reliable Messaging
    Metadata: WS-Policy, WSDL 1.1 - Web Service Definition Language
    Communication Security: WS-Security, WS-SecurityPolicy, WS-SecureConversation, WS-Trust (partial support)
    Messaging Support: WS-Addressing, SOAP 1.1, SOAP 1.2, Message Transmission Optimization Mechanism (MTOM)

Multiple Transports, Protocol Bindings, Data Bindings, and Formats

    Transports: HTTP, Servlet, JMS, In-VM and many others via the Camel transport for CXF such as SMTP/POP3, TCP and Jabber
    Protocol Bindings: SOAP, REST/HTTP, pure XML
    Data bindings: JAXB 2.x, Aegis, Apache XMLBeans, Service Data Objects (SDO), JiBX
    Formats: XML Textual, JSON, FastInfoset
    Extensibility API allows additional bindings for CXF, enabling additional message format support such as CORBA/IIOP


http://cxf.apache.org

WebService请求的几种方式

参考技术A 一、eclipse工具生成wsdl文件请求:

next-finish可以自己选择路径,会生成

接下来就可以直接调用了(可以看到引用了soapPort类,里面有你接口的方法,直接调用就好了)

二、通过axis请求:

先引入 org . apache . axis 包,https://mvnrepository.com/artifact/org.apache.axis/axis/1.4

这是工具类

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

public class axis

    public static String axis1(String user, String password)

        Object ret = null;

        try

            //调用webservice地址     

            String url = "xxxxxxxxx?wsdl";

            //调用方法名

            String method = "xxxxxxx";

            Service service = new Service();

            //通过service创建call对象   

            Call call = (Call) service.createCall();

            //设置服务地址

            call.setTargetEndpointAddress(new java.net.URL(url));

            //设置调用方法

            call.setOperationName(method);

            call.setUseSOAPAction(true);

            //添加方法的参数,有几个添加几个

            //inLicense是参数名,XSD_STRING是参数类型,IN代表传入

            call.addParameter("参数名",org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);

            call.addParameter("参数名", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);

            //设置返回类型 

            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);

            try

                //使用invoke调用方法,Object数据放传入的参数值

                ret = call.invoke(new Object[] user, password );

            catch (Exception e)

                e.printStackTrace();

           

            //输出返回信息

            System.out.println("result===" + ret.toString());

        catch (Exception e)

            e.printStackTrace();

       

        return ret.toString();

   

以上是关于java开发webservice接口有几种方式的主要内容,如果未能解决你的问题,请参考以下文章

WebService请求的几种方式

动态调用WebService接口的几种方式

JAVA发送手机短信

java发送手机短信

怎么调用webservice接口

java实现多态有几种方式?分别是啥?