錯誤代碼片斷:
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
//設定服務提供者的地址
EndpointReference targetEPR =
new
EndpointReference(
"http://localhost:8080/Hello"
);
options.setTo(targetEPR);
//設定所要調用的服務的操做
QName opGetHello =
new
QName(
"http://Hello"
,
"sayHello"
);
Class[] returnTypes =
new
Class [] { String.
class
};
//設定調用的方法的參數值
Object[] opGetHelloArgs =
new
Object[] {
"UFO"
};
//獲得調用的結果
Object[] response = serviceClient.invokeBlocking(opGetHello,opGetHelloArgs,returnTypes);
這句報錯以下:
//
The type org.apache.axiom.om.OMElement cannot be resolved. It is indirectly referenced from required .class files
通過調查,由於build path 下面我只引用了axis2-1.6.2.jar.可是axis2在這裏依賴於axiom-api,因此我後來經過maven的repository搜索了axiom.我把最新版的依賴加入,以下:
<dependency>
<
groupId
>
org.apache.axis2
</
groupId
>
<
artifactId
>
axis2
</
artifactId
>
<
version
>
1.6.2
</
version
>
</
dependency
>
<
dependency
>
<
groupId
>
org.apache.ws.commons.axiom
</
groupId
>
<
artifactId
>
axiom-api
</
artifactId
>
<
version
>
1.2.13
</
version
>
</
dependency
>
OK.這個依賴好像還依賴了很大一堆其餘的jar.問題搞定.