to rainight(雨夜聆风): soap也是一种web service ,我现在已经写出来一个soap客户端程序,它的原理就是向web server的一个servlet请交一个http请求。web server上的一个servlet也可以获取这个请求,但是现在我不知道web server如何读出soap请求内容,即:不知道如何取得请求的xml文档。怎样编写soap服务器端?怎样解析提交的文档?怎样发送回去一个SOAP响应?
to bdsc(): socket适用于局域网,我需要能在internet上顺利通讯的解决方案啊。 to sharetop(老大不小) : 是的,我现在就是想要一个webservice,我手边没有讲jms和soap的书,有一本是讲j2ee的,稍带讲了讲jms,很诲涩难懂,网上也没找着好的教程。另外,jms客户端能用其他语言实现吗?有windows平台上的jms API吗?
imho, you can think it as a data integration case, not a system integration one. From your description, the main purpose of your system is to gather the data from all diverse sub-systems. There are no relations with remote method invocation(rmi) or formerly called remote process call(rpc). All you need is sending data from every node. So the key aspect of your design shound be focused on creating a uniform message/data format. Of course, XML is your most suitable choice.And then choose the XML transfer method to implement your demand. SOAP is somewhat hot now for it can send XML through HTTP. So the SOAP over HTTPS will match your system. The last and the most boring thing is to write soap client code for every programing language the nodes used in your sub-systems. For example, you should use DELPHI to create a proxy, retrieving useful data, encapsulating to pre-defined XML format and transfering to the center storage system. Also you may have Java powered sub-system, MS powered ones like VB and VC, etc. Write that kind of SOAP client using those languages. I hope you have so many wonderful people working for you.Moreover, your consideration is correct on the problem you face - it is a message transfer problem. But do not choose some technologies SOUNDS LIKE catering your need. JMS is one kind of message services used in java system and mostly it will facilite loose-coupled system integration and asynthronized processing. Remember it is java-specific. On the other hand, web services let you invoke methods in remote machine and regardless whatever the OS, the programming language and so on in the remote machine. It is too powerful to your system - you want XML transfer, it give you remote method invocation.
soap也是一种web service ,我现在已经写出来一个soap客户端程序,它的原理就是向web server的一个servlet请交一个http请求。web server上的一个servlet也可以获取这个请求,但是现在我不知道web server如何读出soap请求内容,即:不知道如何取得请求的xml文档。怎样编写soap服务器端?怎样解析提交的文档?怎样发送回去一个SOAP响应?
{
public static java.net.URL[] _KnownServiceLocations= null;
private org.apache.soap.rpc.Call call=new org.apache.soap.rpc.Call();
private java.net.URL url= null;
private java.lang.String SOAPActionURI = "";
private org.apache.soap.encoding.SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
static
{
try{
_KnownServiceLocations= new java.net.URL[]{
new java.net.URL("http://localhost/soaprate/servlet/rpcrouter")
};
}catch(java.net.MalformedURLException e ){_KnownServiceLocations= new java.net.URL[0];};
}
public ExchangeRate_ServiceBinding(java.net.URL endPointURL)
{
call.setTargetObjectURI("urn:exchangerate-service");
call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/");
this.url = endPointURL;
this.SOAPActionURI = "urn:exchangerate-service";
}
public synchronized java.lang.String getTargetAmount (java.lang.String meth3_inType1, java.lang.String meth3_inType2, java.lang.String meth3_inType3) throws org.apache.soap.SOAPException
{
if(url == null) throw new org.apache.soap.SOAPException(org.apache.soap.Constants.FAULT_CODE_CLIENT, "A URL must be specified \"ExchangeRate_ServiceBinding\"." );
this.call.setMethodName("getTargetAmount");
java.util.Vector parms = new java.util.Vector(3);
parms.addElement( new org.apache.soap.rpc.Parameter("meth3_inType1", java.lang.String.class, meth3_inType1, null));
parms.addElement( new org.apache.soap.rpc.Parameter("meth3_inType2", java.lang.String.class, meth3_inType2, null));
parms.addElement( new org.apache.soap.rpc.Parameter("meth3_inType3", java.lang.String.class, meth3_inType3, null));
this.call.setParams(parms);
org.apache.soap.rpc.Response resp = this.call.invoke(url, SOAPActionURI);
if(resp.generatedFault())
{
org.apache.soap.Fault fault = resp.getFault();
throw new org.apache.soap.SOAPException(fault.getFaultCode(), fault.getFaultString());
}
return (java.lang.String)resp.getReturnValue().getValue();
}
}
写好你的服务器端核心逻辑程序代码,参考它的文档使用wsdl2java和java2wsdl两个工具可以生成所以你需要的代码,你就不用直接和soap打交道了,真的很方便,我刚做过。同时用wsdd文件部署好web服务就可以使用了。
如有其他问题可以发信息给我。还有不要用jb的web service插件,因为这个插件也是用axis,但版本很低。推荐直接去apache网站下载一个最新班。个人感觉jms比soap传输起来方便很多,因为xml一旦数据多了,速度下降很明显。
socket适用于局域网,我需要能在internet上顺利通讯的解决方案啊。
to sharetop(老大不小) :
是的,我现在就是想要一个webservice,我手边没有讲jms和soap的书,有一本是讲j2ee的,稍带讲了讲jms,很诲涩难懂,网上也没找着好的教程。另外,jms客户端能用其他语言实现吗?有windows平台上的jms API吗?
axis www.apache.org上有。
jms客户端好像只能用java,倒是jms的实现可以用多种语言来实现。
谢谢指点,我去sun网站看了相关文档。
我更趋向于weblogic中的jms server。to patrickwang():
你觉得SOAP比JMS更适合解决我的问题?请留下QQ好吗?
1 发现数据不完整.不适合做商业应用(像QQ一样的软件可考虑)
2 数据传递问题.不管是XML数据格式,还是其它.都会是字节传输.
3 还是考虑用WEB SERVICE.把数据压缩成流.调用远程接口进行传输.
4 HTTP是一种透过防火墙的协议.与TCP/IP无关.(写代码不用考虑这些问题)
5 在传输的时候最好加上头字节等信息.即数据包体.
6 形成服务器与客户接收的CRC检验检查.
7 这样可保证达到数据完整性.