博學而篤志,好問而近思

          【原創】關于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 冰川 閱讀(20128) 評論(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的幫助

          朋友的博客

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          快樂工作—享受生活
          主站蜘蛛池模板: 达州市| 凤山县| 高唐县| 南部县| 常熟市| 卫辉市| 大渡口区| 嵩明县| 原平市| 老河口市| 叙永县| 阳西县| 韶山市| 潜山县| 铁力市| 宜春市| 塔河县| 靖远县| 叶城县| 昌黎县| 昭平县| 张家港市| 拉孜县| 奉新县| 富顺县| 遂平县| 巴林左旗| 鹤山市| 衡水市| 大庆市| 卢氏县| 清新县| 牟定县| 西安市| 镇远县| 靖远县| 德保县| 高青县| 泰州市| 凌海市| 青海省|