【Web Service】Apache Tuscany發佈SOAP

準備工做:

>下載SCA-Java-2.0包html

地址:http://tuscany.apache.org/sca-java-2x-releases.htmljava

選擇相應系統下Binary類型的包,解壓縮web

>添加jar包apache

添加tuscany/lib目錄下,如下3個jar包:api

tuscany-base-runtime-aggregation-2.0.jarapp

tuscany-binding-ws-runtime-axis2-aggregation-2.0.jarwebapp

tuscany-sca-api-2.0.jaride

 

一、編輯web.xml文件測試

添加URL過濾url

複製代碼

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
    <display-name>SOAPServer</display-name>
    <filter>
        <filter-name>tuscany</filter-name>
        <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>  
    </filter>  
    <filter-mapping>  
        <filter-name>tuscany</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping></web-app>

複製代碼

 

二、新建Service接口文件

標記interface @Remotable

定義服務開放的方法

複製代碼

package com.example.service;import org.oasisopen.sca.annotation.Remotable;

@Remotablepublic interface IHelloWorldService {    public String say(String from);
    
}

複製代碼

 

三、新建Service接口實現類

複製代碼

package com.example.service.impl;import com.example.service.IHelloWorldService;public class HelloWorldServiceImpl implements IHelloWorldService {

    @Override    public String say(String from) {        return "Hello, " + from;
    }

}

複製代碼

 

四、新建.composite配置文件

定義組件(<component>)helloworld,實現類(<implementation.java>)爲「com.example.service.impl.HelloWorldServiceImpl」

定義服務(<service>),名爲「IHelloWorldService」,綁定web service(<blinding.ws>)

複製代碼

<?xml version="1.0" encoding="UTF-8"?><composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
           targetNamespace="http://service.example.com"
           name="helloworld">

    <component name="helloworld">
        <implementation.java class="com.example.service.impl.HelloWorldServiceImpl"/>
        <service name="IHelloWorldService">  
           <binding.ws/>
        </service>
    </component></composite>

複製代碼

 

測試:

http://localhost:8080/HelloWorldServer/helloworld/IHelloWorldService?wsdl

相關文章
相關標籤/搜索