博学而笃志,好问而近思

【原创】关于Web Services以及Axis2技术(客户端和服务器端实现)

                      Web Services以及Axis2技术之二

    本篇是继关于Axis2发布Web Service之后的又一随笔,此篇的主要任务是讲述使用Axis2开发客户端和服务器端的具体实现。相信大家在看本篇的时候已经具备了一定的Web Service开发基础,因此我主要是以例子的方式来说明,文字会相对较少。同时,我会在最后提供几个优秀的网址给大家。

    例一(简单的字符串传送服务实现)

客户端
com.udm.iudmservice.IUDMServiceStub stub = new com.udm.iudmservice.IUDMServiceStub(); 
com.udm.iudmservice.types.GetUserAllRegServices param234 =  (com.udm.iudmservice.types.GetUserAllRegServices) getTestObject (com.udm.iudmservice.types.GetUserAllRegServices.class);
GetUserAllRegServicesResponse resp = stub.getUserAllRegServices(param234);
OMElement ret = resp.get_return()[0];
System.out.println(ret.getText());                               //此为测试语句
服务器端:

GetUserAllRegServicesResponse res = new GetUserAllRegServicesResponse();
OMElement resp = fac.createOMElement("Return", omNs);
resp.setText("返回的结果!");
System.out.println("返回结果为:" + resp.getText());  //此为测试语句
res.set_return(new OMElement[] { resp });

    例二(文件传送的具体实现)

客户端:
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMText;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
 
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.namespace.QName;
import java.io.File;
import java.io.InputStream;
 
public class FileTransferClient {
   private static EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8080/axis2/services/interop");
  
   public static boolean upload(String mailboxnum, short greetingType, File file, String fileType) {
     try {
      OMElement data = buildUploadEnvelope(mailboxnum, greetingType, file, fileType);
      Options options = buildOptions();
      ServiceClient sender = new ServiceClient();
      sender.setOptions(options);
      System.out.println(data);
      OMElement ome = sender.sendReceive(data);
      System.out.println(ome);
      String b = ome.getText();
      return Boolean.parseBoolean(b);
     }
     catch(Exception e) {
      
     }
     return false;
   }
   public static InputStream download(String mailboxnum, short greetingType, String FileType) {
     try {
       OMElement data = buildDownloadEnvelope(mailboxnum, greetingType, FileType);
       Options options = buildOptions();
       ServiceClient sender = new ServiceClient();
       sender.setOptions(options);
       System.out.println(data);
       OMElement ome = sender.sendReceive(data);
       System.out.println(ome);
       OMText binaryNode = (OMText) ome.getFirstOMChild();
       DataHandler actualDH = (DataHandler) binaryNode.getDataHandler();
       return actualDH.getInputStream();
      }
      catch(Exception e) {
      }
     return null;
   }
  
   private static OMElement buildUploadEnvelope(String mailboxnum, short greetingType, File file, String FileType) {
     DataHandler expectedDH;
     OMFactory fac = OMAbstractFactory.getOMFactory();
     OMNamespace omNs = fac.createOMNamespace("http://example.org/mtom/data", "x");
     OMElement data = fac.createOMElement("upload", omNs);
     OMElement fileContent = fac.createOMElement("fileContent", omNs);
     FileDataSource dataSource = new FileDataSource(file);
     expectedDH = new DataHandler(dataSource);
     OMText textData = fac.createOMText(expectedDH, true);
     fileContent.addChild(textData);
     OMElement mboxnum = fac.createOMElement("mailboxnum", omNs);
     mboxnum.setText(mailboxnum);
     OMElement gtType = fac.createOMElement("greetingType", omNs);
     gtType.setText(greetingType+"");
     OMElement fileType=fac.createOMElement("fileType", omNs);
     fileType.setText(FileType);
  
     data.addChild(mboxnum);
     data.addChild(gtType);
     data.addChild(fileType);
     data.addChild(fileContent);
     return data;
   }
   private static OMElement buildDownloadEnvelope(String mailboxnum, short greetingType, String FileType) {
     OMFactory fac = OMAbstractFactory.getOMFactory();
     OMNamespace omNs = fac.createOMNamespace("http://example.org/mtom/data", "x");
     OMElement data = fac.createOMElement("download", omNs);
     OMElement mboxnum = fac.createOMElement("mailboxnum", omNs);
     mboxnum.setText(mailboxnum);
     OMElement gtType = fac.createOMElement("greetingType", omNs);
     gtType.setText(greetingType+"");
     OMElement fileType=fac.createOMElement("fileType", omNs);
     fileType.setText(FileType);
     data.addChild(mboxnum);
     data.addChild(gtType);
     data.addChild(fileType);
     return data;
   }
   private static Options buildOptions() {
     Options options = new Options();
     options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
     options.setTo(targetEPR);
     // enabling MTOM in the client side
     options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
     options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
     return options;
   }
   public static void main(String agrs[]) {    //此为测试主函数
     String file = "C:/deploy.wsdd";
     short gt = 1;
     String mn = "20060405";
     String ft="wsdd";
     boolean rtv = upload(mn,gt,new File(file),ft);
     System.out.println(rtv);
     InputStream is = download(mn,gt,ft);
   }
}
服务器端

import org.apache.axiom.attachments.utils.IOUtils;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMText;
import org.apache.axis2.AxisFault;
import java.io.FileOutputStream;
import java.io.*;
import java.util.Iterator;
 
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
 
public class interopService {
 public static final String TMP_PATH = "c:/tmp";
 public OMElement upload(OMElement element) throws Exception {
    OMElement _fileContent = null;
    OMElement _mailboxnum = null;
    OMElement _greetingType = null;
    OMElement _fileType = null;
    System.out.println(element);
    for (Iterator _iterator = element.getChildElements(); _iterator.hasNext();) {
      OMElement _ele = (OMElement) _iterator.next();
      if (_ele.getLocalName().equalsIgnoreCase("fileContent")) {
        _fileContent = _ele;
      }
      if (_ele.getLocalName().equalsIgnoreCase("mailboxnum")) {
        _mailboxnum = _ele;
      }
      if (_ele.getLocalName().equalsIgnoreCase("greetingType")) {
        _greetingType = _ele;
      }
      if (_ele.getLocalName().equalsIgnoreCase("fileType")) {
        _fileType = _ele;
      }
    }
 
    if (_fileContent == null || _mailboxnum == null || _greetingType== null || _fileType==null) {
      throw new AxisFault("Either Image or FileName is null");
    }
 
    OMText binaryNode = (OMText) _fileContent.getFirstOMChild();
 
    String mboxNum = _mailboxnum.getText();
    String greetingType = _greetingType.getText();
    String fileType = _fileType.getText();
 
    String greetingstoreDir = TMP_PATH+"/"+mboxNum;
    File dir = new File(greetingstoreDir);
    if(!dir.exists()) {
      dir.mkdir();
    }
    String filePath = greetingstoreDir+"/"+greetingType+"."+fileType;
    File greetingFile = new File(filePath);
    if(greetingFile.exists()) {
      greetingFile.delete();
      greetingFile = new File(filePath);
    }
   
    // Extracting the data and saving
    DataHandler actualDH;
    actualDH = (DataHandler) binaryNode.getDataHandler();
    
    FileOutputStream imageOutStream = new FileOutputStream(greetingFile);
    InputStream is = actualDH.getInputStream();
    imageOutStream.write(IOUtils.getStreamAsByteArray(is));
    // setting response
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace ns = fac.createOMNamespace("http://example.org/mtom/data", "x");
    OMElement ele = fac.createOMElement("response", ns);
    ele.setText("true");
   
    return ele;
 }
 public OMElement download(OMElement element) throws Exception {
    System.out.println(element);
    OMElement _mailboxnum = null;
    OMElement _greetingType = null;
    OMElement _fileType = null;
    for (Iterator _iterator = element.getChildElements(); _iterator.hasNext();) {
      OMElement _ele = (OMElement) _iterator.next();
      if (_ele.getLocalName().equalsIgnoreCase("mailboxnum")) {
        _mailboxnum = _ele;
      }
      if (_ele.getLocalName().equalsIgnoreCase("greetingType")) {
        _greetingType = _ele;
      }
      if (_ele.getLocalName().equalsIgnoreCase("fileType")) {
        _fileType = _ele;
      }
    }
    String mboxNum = _mailboxnum.getText();
    String greetingType = _greetingType.getText();
    String fileType = _fileType.getText();
    String filePath = TMP_PATH+"/"+mboxNum+"/"+greetingType+"."+fileType;
    FileDataSource dataSource = new FileDataSource(filePath);
    DataHandler expectedDH = new DataHandler(dataSource);
   
    OMFactory fac = OMAbstractFactory.getOMFactory();
   
    OMNamespace ns = fac.createOMNamespace("http://example.org/mtom/data", "x");
    OMText textData = fac.createOMText(expectedDH, true);
    OMElement ele = fac.createOMElement("response", ns);
    ele.addChild(textData);
    return ele;
 }
}
Services.xml配置文件:
<servicename="MTOMService">
    <description>
        This is a sample Web Service with two operations,echo and ping.
    </description>
    <parametername="ServiceClass"locked="false">sample.mtom.interop.service.interopService</parameter>
    <operationname="upload">
        <actionMapping>urn:upload</actionMapping>
        <messageReceiverclass="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
    </operation>
      <operationname="download">
        <actionMapping>urn:download</actionMapping>
        <messageReceiverclass="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
    </operation>
</service>

两个学习网址http://www-128.ibm.com/developerworks/cn/(IBM的开发网中国站)
                                http://www.apache.org/ (Apache组织的官方网站)

    最后:祝福大家在程序的天空里越飞越高!!!


                                                                                                                         ------ 冰川
                                                                                                                              2006-9-1


posted on 2006-09-01 10:17 冰川 阅读(20079) 评论(48)  编辑  收藏

评论

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-09-14 21:09 shaofan

axis2有什么不同?新旧版本好像是并行开发的  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-09-15 14:29 冰川

@shaofan:
不是并行发行的,Axis2.0 的1.0版本是最新的版本2006-5-4号发布的。
只所以有个Axis(1.x)是为了提供对Axis以前版本用户的支持。
因为并不是每个项目都会升级到最新版本,有的用户习惯了用老版本的。  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-11-10 11:07 shrimplucky

你好,现在刚入手axis2 ,想利用里面的例子试验从WSDL文件生成skeleton,依据userguide,可是编译时竟找不到xsd中的类,可明明对应的class 文件生成了。
  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-11-10 14:17 冰川

找不到xsd中的类?不知道你具体想要做什么事。  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-11-12 15:59 shrimplucky

@冰川

用它的build.xml直接处理了,呵呵

问个问题,Axis2是否支持Spring AOP,我想使用拦截功能,考虑到使用 Handler 拦截是在 message going out时拦截,如果一个操作不返回值时handler是否也能在操作完成之后进行拦截呢?

XFire用过吗?它的Axis2有什么差别?谢谢

  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-11-12 16:15 冰川

@shrimplucky:
1.很抱歉,这个问题我没接触过
2.XFire听说也是个很不错的东东,但我没有用过

  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-11-18 16:13 neusoft

"org.apache.axis2.AxisFault: Module not found"

classpath设了addressing-1.0.mar了,还是不好用。  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-12-01 18:12 霄羽

大文件上传设置了文件缓存如下:
<parameter name="cacheAttachments" locked="false">true</parameter>
<parameter name="attachmentDIR" locked="false">C:/upload/tep/</parameter>
<parameter name="sizeThreshold" locked="false">4000</parameter>

不知道怎么回事,上传文件少4个字节,痛苦啊  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-12-19 18:28 晓刚

问一个很弱的问题,客户端生成器生成的java代码,怎么调用啊?基于Axis2开发  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-12-19 21:03 嘎崩豆

为什么会出现 services.xml not found for service ,说是找不到对应的aar文件,可是明明是对照着写的啊  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-12-19 21:04 嘎崩豆

我的问题是在部署一个自己的AddService时出现的,想利用反回两个数的和来进行验证  回复  更多评论   

# re: 【原创】关于Web Serviece以及Axis2技术(客户端和服务器端实现) 2006-12-20 14:55 冰川

@晓刚:
俺没有使用过客户端生成器。。。
@嘎崩豆:
你是对照哪里的写的啊?检查一下你Web Services的配置,看看路径是不是对的?

  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-03-14 17:09 啊啊

可以用eclipse的axis2-java2wsdl-maven-plugin-1.1.1和axis2-wsdl2code-maven-plugin-1.1.1插件生成client端的stub和server端的skeletone.非常简单axis2的官方网站上有下载.  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-03-14 17:16 冰川

谢谢支持。。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现)[未登录] 2007-04-17 09:52 soa

想问楼主一个问题,通过axis2客户端调用ws,返回的结果中,含有中文,如果结果只有一条,我还好处理,直接用e.gettext(),就得到我想要的,但是如果有多条结果的话,如果我用e.getText(),那么结果就乱了,不能一一对应起来,然后我想用dom4j解析,但是解析出来之后,中文都是乱码,怎么设置编码都不对,请问有什么好的解决办法吗?  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现)[未登录] 2007-04-17 09:59 soa

<ns1:GoodsCheckResponse xmlns:ns1="http://www.example.org/goodsflow/">
<id>3</id>
<id>4</id>
<hwmc>abab</hwmc>
<hwmc>鍙扮伅</hwmc>
<dw>涓?</dw>
<dw>涓?</dw>
</ns1:GoodsCheckResponse>
返回结果,结构如下,然后我想用先讲上面的结果转换成字符串,然后用dom4j的documentHelper换成document,再用dom4j解析,取出来的就是乱码。
我觉得问题可能是在转换的时候产生的,但是不转换,又不懂怎么解析,请问有什么好方法吗  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-05-18 14:07 cmzhao

请问这个是什么问题???
org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog at [row,col {unknown-source}]: [1,0]
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:434)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:373)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
at sample.addressbook.service.MsgServiceMsgServiceSOAP11Port_httpStub.getMsg(MsgServiceMsgServiceSOAP11Port_httpStub.java:205)
at sample.addressbook.adbclient.AddressBookADBClient.main(AddressBookADBClient.java:45)
  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-05-19 14:26 冰川

@cmzhao:
WstxEOFException是在解析XML文件时遇到错误,导致这个错误原因Exception thrown during parsing, if an unexpected EOF is encountered. Location usually signals starting position of current Node。
prolog at [row,col {unknown-source}]: [1,0]是在解析XML文件时未知来源,可能是你的WSDL命名空间错误,去检查一下。

@soa:
你的XML文件如果是encoding=“UTF-8”,把它改成encoding=“GBK”。
另外,看看你的数据库的字符编码设置,如果不是“GBK”的则要需要转化,还有你全局配置文件里的设置,如Web.xml里的字符编码,总之影响你的显示的中文内容的相关字符编码配置最好一致。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现)[未登录] 2007-07-27 11:37 mask

public class Axis2Client {
private static EndpointReference targetEPR =
new EndpointReference("http://202.*.*.*:8080/axis2/services/Version");
//这一行如果改为localhost:8080则正常调用
public static void main(String[] args) {
try {
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
options.setTo(targetEPR);
// 待调用服务的名称
QName opGetVersion = new QName("http://axisversion.sample/xsd", "getVersion");
// 服务参数
String str = "hello";
Object[] opGetVersionArgs = new Object[] { str };
// 返回类型
Class[] returnTypes = new Class[] { String.class };
// 阻塞调用,得到返回值
Object[] response = serviceClient.invokeBlocking(opRedToGreen,
opRedToGreenArgs, returnTypes);
System.out.println(response[0]);
} catch (Exception e) {
e.printStackTrace();
}
}
}

上面的示例代码是访问axis2 1.1的version服务的,当EPR为IP地址时,会出现以下错误:
org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:271)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:202)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:579)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:95)
at Axis2Client.main(Axis2Client.java:36)
但是将ERP中的IP地址改为localhost时,则正常返回。
请问这是什么问题,谢谢了!  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-06 09:20 xl

我也遇到同样问题,service的入口地址只能用localhost或127.0.0.1,不能使用实际的IP地址。否则会报错:org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]。

Axis1.1,1.2,1.3RC都试过了。
环境:
XP Home SP2
Tomcat 5.0.28
java 1.4.2_11  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-06 11:15 冰川

@mask and @xl
很抱歉,最近很忙,所以有一阵子没上来了
是同样的问题,我就一起回了啊,调试本机的Web Service服务程序要用localhost或127.0.0.1,原因是当你设置的是实际IP地址,你的客户端程序将会通过DNS服务器来找这个Web Service服务程序所在服务器的IP地址,如果你的计算机或服务器是独立的IP地址则不会出现错误。如果你的电脑是通过的代理上网是动态分配的IP,或是一个域下面的局域网IP则不行。总而言之,你的Web Service服务程序要发布在拥有独立IP的服务端,客户端才能够通过向这个IP发送请求来获得服务。


  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-06 11:40 xl(wxxl22@163.com)

to 冰川
我影射一个本地域名也不可以,比如(www.xl.com->10.xx.xx.xx),ping一下www.xl.com可以ping通10.xx.xx.xx。
然后我把EndpointReference targetEPR = new EndpointReference(
"http://localhost:8080/axis2/services/Version");
中的localhost换成www.xl.com还是同样的错误。
我觉得不是IP地址的问题,照这样说WebService岂不是不能发布在局域网中了。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-07 09:18 xl(wxxl22@163.com)

我还发现入口地址改成IP地址后,INOnly操作能够正确调用,比如StockQuoteService的update操作,但是INOut操作调用失败,比如StockQuoteService的getPrice操作,这说明不是寻址问题.  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-15 13:56 lizhaning

晕到,有那么复杂么,IP不用改变,把你们的防火墙关掉,一试就OK.  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-20 10:39 xl(wxxl22@163.com)

不是防火墙的问题,我试过了,没用。
如果是防火墙阻挡,不可能INOnly操作能够正确调用,INOut操作调用失败,应该都失败的。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-22 09:41 xl(wxxl22@163.com)

上面说错了,今天用SOAPMonitor看了一下,改为IP地址后服务端确实没有接收到请求信息,因此所有操作都失败。但是确实关闭防火墙也不行,再查原因中…………  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-22 13:57 lizhaning

把杀毒软件都停掉试下!:)我的就不会出现错误了,
为什么会这样,原因我也在查...  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-22 14:02 lizhaning

关键我想请教下如何传递容器对象,比如List,如何在客户端得到一个List对象?
谁能帮解答下,谢谢.  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-28 16:55 wu

我想问一个可能比较简单的问题, 怎么定位aar包里的文件?我把一个文件放在aar包里的根目录下,调用的时候不给出路径,就会出错,说找不到这个文件。可我试了很多路径都不行。谁知道的话,可否给个答案,谢谢.  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-29 13:28 xl(wxxl22@163.com)

试了一下,确实是杀毒软件的原因,我装的是KB,关闭“WEB反病毒保护”和"反间谍保护"后可正常访问WebServices。

to:izhaning
据我了解不能传递容器对象的,我倒是试过可以传递Pojo数组。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-29 13:45 xl(wxxl22@163.com)

to: wu
我是用MyClass.class.getResource("/").toString();方法取得$tomcat$\webapps\axis2\WEB-INF\classes路径,我把自己的一些配置文件放在了该路径下。这只是个变通的方法,不知道对你有没有用。
另外,你找到正确的方法后告诉我一声。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-08-29 17:37 wu

多谢你的答复。我希望是能把这些文件打包在aar文件里面,而不是放在axis2的classes下面,这样发布更方便一些。不过我在apache axis2的网站下找到答案了: http://ws.apache.org/axis2/faq.html#b1
用getClass().getClassLoader().getResourceAsStream("myResource");
可以搞定了。之前还找了半天,原来这里的问题解答里面就有,真是郁闷。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-29 17:34 wowoer

你们好,我也刚开始弄axis2,也报那个错误,但是,我的是localhost啊,不知道怎么回事,还有说命名空间有问题,这个命名空间应该怎么定义呢??谢谢大家。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-29 17:37 wowoer

http://blog.csdn.net/daryl715/archive/2007/05/09/1602283.aspx我是照这个例子做的,出的org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog,这个错误。弄了2天了。不知道有没有人理我。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 10:19 zhou

to wowoer

我也是照着这个例子做的,没有问题,详细讲一下你的错误是什么?  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 14:59 wowoer

org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:434)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:373)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:520)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:500)
at sample.client.TestClient.main(TestClient.java:29)
  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 15:01 wowoer

这是我的MSN:darlingzhuya@126.com谢谢你帮助我~~  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 15:01 wowoer

我到现在还在解决这个问题。。。。。郁闷中。。。。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 15:03 wowoer

to zhou
今天下班之前,我都会在这里等待!!谢谢你  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 15:26 wowoer

继续等待中....  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 15:59 wowoer

完了。。看来十一之前,我的问题都解决不了了。。。。。带着郁闷过节。。。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 16:45 wowoer

我快下班了。。。  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-09-30 16:51 wowoer

算了,十一可能没有机会上网,希望十一回来,可以解决这个问题。。。谢谢你zhou  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-10-01 08:42 bsr

org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:434)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:373)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:520)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:500)
at sample.client.TestClient.main(TestClient.java:29)
该错误在我关闭卡巴后消失  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-10-08 09:15 wowoer

to bsr: 刚刚上班,我就按照你说的办法试了,但是还是报错,我想,应该不是卡巴的问题。。。。不知道还有没有别的解决办法?谢谢  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2007-10-08 09:20 wowoer

@bsr
不好意思,我刚刚是暂停保护,现在完全关闭,真的就实现了。。。谢谢。。太诡异了,这个问题的根源到底是什么??  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2008-12-30 15:28 筆仩

到底是讨论AXIS呢,还是讨论关于IP的问题???  回复  更多评论   

# re: 【原创】关于Web Services以及Axis2技术(客户端和服务器端实现) 2009-08-17 10:07 歐陽

上傳的文件不完整,打不開,是怎麼回事  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2006年9月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(14)

随笔档案

BlogJava的帮助

朋友的博客

搜索

最新评论

阅读排行榜

评论排行榜

快乐工作—享受生活