2014-11-05 40 views
0

我有2個問題 我想運行軸2樣本。在指令文件的最後部分,有這種線,它說,應該在終端(Ubuntu的)上運行,不能正常工作軸樣本AddressBook異常

java -Djava.ext.dirs=%AXIS2_HOME%\lib;%JAVA_HOME%\jre\lib\ext -cp target/classes org.apache.axis2.jaxws.addressbook.AddressBookClient.class 

我不是這方面的專家,我不是熟悉ubuntu命令。我覺得這是不是一個Ubuntu命令 我得到的錯誤是「無效的作業」

  1. 有人能轉換成Ubuntu的命令呢?

因爲它不工作,我建立使用jar,

mvn clean install 

然後我複製的jar文件,在存儲庫中的servicejars目錄,Axis2中

然後軸線服務器說,該jar不包含WebServices註釋

「在jar:file:/home/dodan/Programs/axis2-1.6.0/repository/servicejars/jaxws-addressbook-1中找不到@WebService註釋的服務實現。 6.0-client.jar中。服務部署失敗。」

所以我把它添加到其不具有註釋(和進口太多)

然而Axis2的服務器仍然SYS原始的Java文件不存在web服務註釋 2.可有人說我是否錯過了什麼?

這裏是java文件,我改變

import javax.xml.namespace.QName; 
import javax.xml.ws.BindingProvider; 
import javax.xml.ws.Dispatch; 
import javax.xml.ws.Service; 
import javax.jws.WebService; 
import java.util.Map; 

/** 
* Simple JAX-WS Dispatch client for the address book service implementation. 
*/ 
@WebService 
public class AddressBookClient { 
    private static String NAMESPACE = "http://addressbook.jaxws.axis2.apache.org"; 
    private static QName QNAME_SERVICE = new QName(NAMESPACE, "service"); 
    private static QName QNAME_PORT = new QName(NAMESPACE, "port"); 
    private static String ENDPOINT_URL = "http://localhost:8080/axis2/services/AddressBookImplService.AddressBookImplPort"; 

private static String ADD_ENTRY_BODY_CONTENTS = 
    "<ns1:addEntry xmlns:ns1=\"http://addressbook.jaxws.axis2.apache.org\">" + 
     "<ns1:firstName xmlns=\"http://addressbook.jaxws.axis2.apache.org\">myFirstName</ns1:firstName>" + 
     "<ns1:lastName xmlns=\"http://addressbook.jaxws.axis2.apache.org\">myLastName</ns1:lastName>" + 
     "<ns1:phone xmlns=\"http://addressbook.jaxws.axis2.apache.org\">myPhone</ns1:phone>" + 
     "<ns1:street xmlns=\"http://addressbook.jaxws.axis2.apache.org\">myStreet</ns1:street>" + 
     "<ns1:city xmlns=\"http://addressbook.jaxws.axis2.apache.org\">myCity</ns1:city>" + 
     "<ns1:state xmlns=\"http://addressbook.jaxws.axis2.apache.org\">myState</ns1:state>" + 
    "</ns1:addEntry>"; 

private static String FIND_BODY_CONTENTS = 
    "<ns1:findByLastName xmlns:ns1=\"http://addressbook.jaxws.axis2.apache.org\">" + 
     "<ns1:lastName xmlns=\"http://addressbook.jaxws.axis2.apache.org\">myLastName</ns1:lastName>" +   
    "</ns1:findByLastName>"; 

public static void main(String[] args) { 
    try { 
     System.out.println("AddressBookClient ..."); 

     Service svc = Service.create(QNAME_SERVICE); 
     svc.addPort(QNAME_PORT, null, ENDPOINT_URL); 

     // A Dispatch<String> client sends the request and receives the response as 
     // Strings. Since it is PAYLOAD mode, the client will provide the SOAP body to be 
     // sent; the SOAP envelope and any required SOAP headers will be added by JAX-WS. 
     Dispatch<String> dispatch = svc.createDispatch(QNAME_PORT, 
       String.class, Service.Mode.PAYLOAD); 

     // Invoke the Dispatch 
     System.out.println(">> Invoking sync Dispatch for AddEntry"); 
     String response = dispatch.invoke(ADD_ENTRY_BODY_CONTENTS); 
     System.out.println("Add Entry response: " + response); 

     System.out.println(">> Invoking Dispatch for findByLastName"); 
     String response2 = dispatch.invoke(FIND_BODY_CONTENTS); 
     System.out.println("Find response: " + response2); 
    } catch (Exception e) { 
     System.out.println("Caught exception: " + e); 
     e.printStackTrace(); 
    } 
} 
} 

回答

1

您使用環境變量的Windows語法。

而不是%AXIS_HOME%,您將使用$AXIS_HOME

也就是說,你現在不需要任何版本的Axis來了解Web服務。 JDK for Java 6和更新版本中存在JAX-WS實現。

有很多關於它的教程。

+0

謝謝,但我需要學習軸 順便說一句,你可以將整行轉換爲Linux的EN – 2014-11-05 07:38:05