我創建了5種不同類型的服務。 A,B,C,d,E。使用Apache Axis如何從我的客戶端使用Web服務?
從單個java客戶端我將調用所有這5個服務,並給每個服務3個參數。
我創建了客戶端。像這樣是對的?
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class ServicesCaller
{
String A="";
String B="";
String C="";
public void services(String start,String end,String comfort)
{
try
{
String endpoint1="http://localhost:8080/callser/services/A1";
String endpoint2="http://localhost:8080/callser/services/A2";
String endpoint3="http://localhost:8080/callser/services/A3";
String endpoint4="http://localhost:8080/callser/services/A4";
String endpoint5="http://localhost:8080/callser/services/A5";
Service service=new Service();
Call call=(Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint1));
call.setTargetEndpointAddress(new java.net.URL(endpoint2));
call.setTargetEndpointAddress(new java.net.URL(endpoint3));
call.setTargetEndpointAddress(new java.net.URL(endpoint4));
call.setTargetEndpointAddress(new java.net.URL(endpoint5));
call.setOperationName(new QName("http://service.com","firstReturn"));
String ret = (String) call.invoke(new Object[] {start,end,comfort});
}
catch(Exception e)
{
System.out.println(e);
}
}
}
它正確嗎?當我從我的jsp運行時,我得到這個異常
org.xml.sax.SAXException: Deserializing parameter 'arg0': could not find deserializer for type {http://schemas.xmlsoap.org/soap/encoding/}string
我建議您使用wsimport爲您的WSDL生成一個Java客戶端 – ftr 2013-03-05 17:27:07