使用Tuscany,建立web services

Tuscany-ws项目
摘要》
使用Tuscany创建Web services服务
一:安装Tuscany的Eclipse plugin
启动Eclipse后,菜单Help->Software Updates->Find and Install
选择Searh for new features to install ,然后执行New Remote Site
名字:Tusany
URL:http://people.apache.org/~jsdelfino/tuscany/tools/updatesite/*
Remote site ,完成即可

安装完成后,重启eclipse
二:建立Java Project
Tuscany-ws
由于插件已经加入开发工具,因此可以自行建立一个User Library资源,供以引用;

>>一:源代码文件HelloWorld.java

package com.spsoft.tuscany.ws.helloworld;
import org.osoa.sca.annotations.Remotable;
@Remotable
public interface HelloWorld{
String sayHello(String name);
}

>>二:源代码文件HelloWorldImpl.java
package com.spsoft.tuscany.ws.helloworld;
public class HelloWorldImpl implements HelloWorld{
Public String sayHello(String name){
Return “Hello:”+name;
}

}

>>三:helloworld.composite建立在src下
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:c="http://helloworld.ws.tuscany.spsoft.com.cn"
name="helloworld">
<component name="HelloWorldComponent">
<implementation.java class=" com.spsoft.tuscany.ws.helloworld.HelloWorldImpl"/>
<service name="HelloWorld">
<binding.ws uri="http://localhost:9080/HelloWorld"/>
</service>
</component>
</composite>
>>四:建立启动web services的服务类
package com.spsoft.tuscany.ws.helloworld;

import java.io.IOException;

import org.apache.tuscany.sca.host.embedded.SCADomain;

public class HelloWorldServer {
public static void main(String[] args) {
SCADomain scaDomain = SCADomain.newInstance("helloworld.composite");
try {
System.out
.println("HelloWorld server started (press enter to shutdown)");
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
scaDomain.close();
System.out.println("HelloWorld server stopped");
}

}

运行该类时,控制台将会看到以下信息:
2008-5-7 19:35:01 org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping
信息: Added Servlet mapping: http://spsoft-35c9654c:9080/HelloWorld
HelloWorld server started (press enter to shutdown)
此时您可以通过访问
http://spsoft-35c9654c:9080/HelloWorld?wsdl
观看你的服务是否已经成功创建!

                            

你可能感兴趣的:(java,apache,eclipse,Web,SOAP)