• day63-webservice 04.JaxWsServerFactoryBean和SOAP1.2


    <wsdl:definitions xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://server.cxf.rl.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="HelloServiceService" targetNamespace="http://server.cxf.rl.com/">
    <wsdl:types>
    <xs:schema xmlns:tns="http://server.cxf.rl.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://server.cxf.rl.com/" version="1.0">
    <xs:element name="sayHello" type="tns:sayHello"/>
    <xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
    <xs:complexType name="sayHello">
    <xs:sequence>
    <xs:element minOccurs="0" name="arg0" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="sayHelloResponse">
    <xs:sequence>
    <xs:element minOccurs="0" name="return" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    </wsdl:types>
    <wsdl:message name="sayHello">
    <wsdl:part element="tns:sayHello" name="parameters"></wsdl:part>
    </wsdl:message>
    <wsdl:message name="sayHelloResponse">
    <wsdl:part element="tns:sayHelloResponse" name="parameters"></wsdl:part>
    </wsdl:message>
    <wsdl:portType name="HelloService">
    <wsdl:operation name="sayHello">
    <wsdl:input message="tns:sayHello" name="sayHello"></wsdl:input>
    <wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse"></wsdl:output>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="HelloServiceServiceSoapBinding" type="tns:HelloService">
    <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sayHello">
    <soap12:operation soapAction="" style="document"/>
    <wsdl:input name="sayHello">
    <soap12:body use="literal"/>
    </wsdl:input>
    <wsdl:output name="sayHelloResponse">
    <soap12:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="HelloServiceService">
    <wsdl:port binding="tns:HelloServiceServiceSoapBinding" name="HelloServicePort">
    <soap12:address location="http://127.0.0.1:5555/hello"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>

    http://www.cnblogs.com/yanzige/p/5377332.html


    package com.rl.cxf.client;
    
    import com.rl.soap11.HelloService;
    import com.rl.soap11.HelloServiceService;
    
    public class Soap11Client {
       public static void main(String[] args) {
           HelloServiceService hss = new HelloServiceService();
           HelloService hs = hss.getHelloServicePort();
           String result = hs.sayHello("lisi");
           System.out.println(result);
           
    }
    }
    package com.rl.cxf.client;
    
    import com.rl.cxf.server.HelloService;
    import com.rl.cxf.server.HelloServiceService;
    
    public class Soap12Client {
       public static void main(String[] args) {
           HelloServiceService hss = new HelloServiceService();
           HelloService hs = hss.getHelloServicePort();
           String result = hs.sayHello("lisi");
           System.out.println(result);
           
    }
    }
    package com.rl.cxf.server;
    
    import javax.jws.WebService;
    import javax.xml.ws.BindingType;
    
    @WebService
    //@BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING )
    @BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING )
    public class HelloService {    
         public String sayHello(String name){
             return name + " hello";
         }
    }
    package com.rl.cxf.server;
    
    //import org.apache.cxf.frontend.ServerFactoryBean;
    import org.apache.cxf.interceptor.LoggingInInterceptor;
    import org.apache.cxf.interceptor.LoggingOutInterceptor;
    import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
    
    public class MyCXFServer {
       public static void main(String[] args) {
         //创建服务工厂对象
         //ServerFactoryBean sfb = new ServerFactoryBean();
         JaxWsServerFactoryBean sfb = new JaxWsServerFactoryBean();
         //加入输入输出拦截器
         sfb.getInInterceptors().add(new LoggingInInterceptor());
         //sfb.getOutFaultInterceptors().add(new LoggingOutInterceptor());
         sfb.getOutInterceptors().add(new LoggingOutInterceptor());
         //指定服务地址
         sfb.setAddress("http://127.0.0.1:5555/hello");
         //设置服务类
         sfb.setServiceClass(HelloService.class);
         //设置服务类的实例对象
         sfb.setServiceBean(new HelloService());
         //发布服务
         sfb.create();
         System.out.println("server ready...");
       }
    }
  • 相关阅读:
    阐述:SIP协议是什么
    【SIP协议】学习初学笔记
    【协议学习】SIP基本场景分析
    电话的前世今生
    深入浅出SIP协议
    QVariant类及QVariant与自定义数据类型转换的方法
    Qt中如何根据类名来实例化对象
    模板的全特化与偏特化
    为什么c++中,有时可以用类名直接访问非静态成员函数?
    C++引用详解
  • 原文地址:https://www.cnblogs.com/ZHONGZHENHUA/p/7654372.html
Copyright © 2020-2023  润新知