webService_cxf_消息中间件_5.16
2020-12-13 04:09
标签:style blog class code c java 前言:自上周五开始,因为公司刚好来人培训,因为我还在出差,熬了一个周末早9-晚9两天搞完了三天的课程,觉得还不错。。但是很多东西还是要自己摸索的。到今天来一个小结吧。 1.webService 说白了,就是为企业执行SOA的一个工具而已。 2.消息中间件,作为SOA架构的一条esb,即企业服务总线。 简介:这套东西要用到2个webservice(Webservice_Server&webService_Client),一个作为
hwHosting的webservice,一个作为jsClient的。在中间件上的webservice是通过webService_Server来重新部署一个新的地址,也就是说,我在调用java上的webService上时,数据会传到中间件上去。然后到中间件上的时候按照xslt---》javascript的方向来实现。 1.(webService_Server_for_hwHosting),主要是作为hwHosting的webservice,向中间件提供的部分。 2.webService_Server_for_hwHosting,主要用来调用,测试服务 3.webService_Client_for_jsClient 4.下面是一些测试数据。 4.1传入的数据:一定要注意这里面有命名空间,再我处理的时候有很多的不便,所以我加入了一个xslt来去除 这个命名空间。 4.2 xslt文件:一定要注意,在传过来的xml文件中有命名空间,所以我们的xslt文件也要有命名空间,如高亮区 4.3 结果:如图所示,已经将原有的ns2去掉了。 5.下面继续看javascript的写法,主要是看我通过jsHosting传过来的数字,来判断,去调用jsClient的哪个具体的
方法 6.最终返回值:根据我传入的2,返回为testJs2,这样完成了所有的测试。 Stop compliant,just code,just do something even if it maybe
easy a lot.... 很多东西都是在不段的积累中,幸福是来自于追求的路上,而不是获得以后。 webService_cxf_消息中间件_5.16,搜素材,soscw.com webService_cxf_消息中间件_5.16 标签:style blog class code c java 原文地址:http://www.cnblogs.com/weizizhe/p/3731723.html一.概述
二.实现

@WebServicepublic
interface HelloWorld {
@WebMethod
public
String sayHello(@WebParam(name="name")String name);
}
public
class HelloWorldImpl implements
HelloWorld {
public
String sayHello(String name) {
return
"somethind";
}
public
static void
main(String[] args) {
HelloWorldImpl implementor = new
HelloWorldImpl();
JaxWsServerFactoryBean svrFactory = new
JaxWsServerFactoryBean();
svrFactory.setServiceClass(HelloWorld.class);
svrFactory.setAddress("http://127.0.0.1:9898/helloWorld");
svrFactory.setServiceBean(implementor);
svrFactory.getInInterceptors().add(new
LoggingInInterceptor());
svrFactory.getOutInterceptors().add(new
LoggingOutInterceptor());
svrFactory.create();
}
}
public
class HelloClient {
public
static void
main(String[] args) {
JaxWsProxyFactoryBean factory = new
JaxWsProxyFactoryBean();
//factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new
LoggingOutInterceptor());
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://127.0.0.1:1506/services/HelloWorldService.HelloWorldServiceHttpSoap11Endpoint");//这个地址是通过中间件的webService的wsdl文件中的endPoint中找到的
HelloWorld client = (HelloWorld) factory.create();
"color: rgb(255, 0, 0);">String reply = client.sayHello("2"); System.out.println("Server said: "
+ reply);
System.exit(0);
}
}
@WebServicepublic
interface IMultiMethod {
@WebMethod
public
String testJs1(@WebParam(name="name")String name);
@WebMethod
public
String testJs2(@WebParam(name="name")String name);
@WebMethod
public
String testJs3(@WebParam(name="name")String name);
@WebMethod
public
String testJs4(@WebParam(name="name")String name);
}
public
class MultiMethodImpl implements
IMultiMethod {
public
String testJs1(String name) {
return
"testJs1";
}
public
String testJs2(String name) {
return
"testJs2";
}
public
String testJs3(String name) {
return
"testJs3";
}
public
String testJs4(String name) {
return
"testJs4";
}
public
static void
main(String[] args) {
MultiMethodImpl implementor = new
MultiMethodImpl();
JaxWsServerFactoryBean svrFactory = new
JaxWsServerFactoryBean();
svrFactory.setServiceClass(IMultiMethod.class);
svrFactory.setAddress("http://127.0.0.1:2000/iMultiMethod");
svrFactory.setServiceBean(implementor);
svrFactory.getInInterceptors().add(new
LoggingInInterceptor());
svrFactory.getOutInterceptors().add(new
LoggingOutInterceptor());
svrFactory.create();
}
"http://server.zxd.com/">//2
"1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl"
"color: rgb(255, 0, 0);">xmlns:ns2="http://server.zxd.com/"xmlns:i="http://www.w3.org/2001/XMLSchemainstance">
"/ns2:sayHello">"color: rgb(255, 0, 0);">//match会选择在/ns:sayHello命名空间下的部分"name"
/>
2
var
next = output.append(input[0]);
var
methodName=next.getField(‘/sayHello/name‘)
next.setProperty(‘methodName‘,methodName)
switch(methodName){
case
"1":next.setProperty("rhapsody:consumerOperation",‘testJs1‘);break;
case
"2":next.setProperty("rhapsody:consumerOperation",‘testJs2‘);break;
case
"3":next.setProperty("rhapsody:consumerOperation",‘testJs3‘);break;
case
"4":next.setProperty("rhapsody:consumerOperation",‘testJs4‘);break;
}
return>testJs2return>
三:总结