A Smple JAX-WS Service in the CXF Distribution
来源:互联网 发布:苹果mac死机 编辑:程序博客网 时间:2024/05/24 02:41
Writing your Service 1
Wirting your service interface at first 1
Implement your service inerface secondly 1
Writing your service at thirdly 2
Testing your service at last 2
Accessing your service by client 2
Writing your Service
Wirting your service interface at first
1.申明服务提供的接口函数,数量不唯一。
2.做必要的注释
import javax.jws.WebService;
import javax.xml.ws.BindingType;
@WebService
@BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING)
public interface HelloWorld{
String SayHello_TO_Client();
//Add other operations your need
}
Implement your service inerface secondly
1.实现服务提供的接口函数。
@WebService(endpointInterface = "demo.hw.server.HelloWorld",
serviceName = "HelloWorld") //注解命名空间和服务名称
public class HelloWorldImpl implements HelloWorld {
@Override
public String SayHello_TO_Client() {
String str =“say hello to client”
return str;
}
//Add other operations implement your add in interface
}
Writing your service at thirdly
Method-1:
public class Service {
public static void main(String[] args) throws Exception {
HelloWorldImpl helloworldImpl = new HelloWorldImpl();
JaxWsServerFactoryBean factory2 = new JaxWsServerFactoryBean(); factory2.setServiceClass(HelloWorld.class);
factory2.setAddress("http://localhost:9000/helloWorld?wsdl");
//服务地址构成 http://IP:端口号/接口名称(可选)?wsdl
factory2.setServiceBean(helloworldImpl);
factory2.create();
}
Testing your service at last
Pointing your browser at http://localhost:9000/helloWorld?wsdl will display the wsdl for this service
Accessing your service by client
public static String GetServerStr() {
SoapObject soapObject = new SoapObject("http://unknown.namespace/", "SayHello_TO_Client()");
//soapObject.addProperty("byProvinceName", byProvinceName); 如果需要传入参数则通过此方法
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //版本
envelope.bodyOut = soapObject;
envelope.dotNet = false;
envelope.setOutputSoapObject(soapObject);
try {
HttpTransportSE trans = new HttpTransportSE("http://localhost:9000/helloWorld?wsdl");
trans.debug = false; // 调试功能
trans.call(null, envelope);
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (XmlPullParserException e) {
e.printStackTrace();
return null;
}
str = ((SoapObject) envelope.bodyIn).getProperty("return").toString();
return str;
}
- A Smple JAX-WS Service in the CXF Distribution
- WS (CXF) JAX-WS
- Developing a JAX-WS web service
- CXF之JAX-WS
- CXF JAX-WS 注释
- Adding SOAP headers in the JAX-WS
- Apache Axis2, CXF and Sun JAX-WS RI in comparison
- JAX-WS Web Service
- Apache CXF JAX-WS example
- Publishing a RESTful Web Service with JAX-WS
- Web Service学习小结——JAX-WS CXF AXIS2关系
- Web Service学习小结——JAX-WS CXF AXIS2关系
- Web Service学习小结——JAX-WS CXF AXIS2关系
- Web Service学习小结——JAX-WS CXF AXIS2关系
- JAX-WS实现web service
- CXF之JAX-WS Dispatch API
- CXF之JAX-WS Provider API
- JAX-WS 和 XFire 以及CXF比较
- 487-3279
- SAP销售订单税的确定
- opencv windows下VS配置
- RPG Maker XP游戏制作方法(五)
- UVA - 607 Scheduling Lectures
- A Smple JAX-WS Service in the CXF Distribution
- Nginx高并发负载的优化(1)
- linux线程相关函数详解
- u影苦于公开iuykiuyk裤天空
- Tomcat高并发相关配置
- 笔记3:填充图形
- Delphi 中的常用事件
- C++ Q&A
- 破解or逃票