我試圖通過Java Webservice客戶端訪問在線.Net Webservice。訪問.Net Webservice的Java Web服務客戶端
但不幸的是,我得到一個錯誤「連接超時:連接」
下面是我的代碼:
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
public class WebServiceMain {
public static void main(String[] args) {
try {
String endpoint = "http://wsf.cdyne.com/SpellChecker/check.asmx";
Service service = new Service();
Call call = (Call)service.createCall();
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://ws.cdyne.com/CheckTextBodyV2");
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setPortName(new QName("http://ws.cdyne.com/", "check"));
call.setOperationName(new QName("http://ws.cdyne.com/", "CheckTextBodyV2"));
System.out.println(call.invoke(new Object[] {"helo is my name"}));
} catch (Exception e) {
System.err.println(e.toString());
}
}
}
你可以連接到該服務(例如瀏覽器)嗎? – Mat 2011-05-28 11:10:22
@Mat:是的,我可以通過瀏覽器連接並獲取XML結果。但是如果我通過這段代碼訪問,我不是。 – 2011-05-28 11:12:25