当前位置: 代码迷 >> Java Web开发 >> weservice调用Server returned HTTP response code: 500 for URL解决方法
  详细解决方案

weservice调用Server returned HTTP response code: 500 for URL解决方法

热度:17300   发布时间:2013-02-25 21:21:16.0
weservice调用Server returned HTTP response code: 500 for URL
比较急,麻烦帮忙看看。谢谢!


自己写了个xfire+java的webservice,部署成功,在服务器端访问http://localhost:8000/test/service/UserService?wsdl
成功显示:
 <?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions targetNamespace="http://webservice.test.com.cn" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://webservice.test.com.cn" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
- <wsdl:types>
- <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webservice.test.com.cn" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
.........




但是写了个客户端调用http://localhost:8000/test/service/UserService报错:
java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8090/test/service/UserService
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at client.ClientMain.doPost(ClientMain.java:43)
at client.ClientMain.sendInformation(ClientMain.java:77)
at client.ClientMain.main(ClientMain.java:89)




客户端代码:
HttpURLConnection connection = null;
String result ="http://localhost:8090/FAP/service/UserService";
URL url = new URL(result);
connection = (HttpURLConnection)url.openConnection(); 
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");


------解决方案--------------------------------------------------------
Java code
String endpoint = "http://localhost:8090/FAP/service/UserService";org.apache.axis.client.Service service = new org.apache.axis.client.Service();org.apache.axis.client.Call call = (org.apache.axis.client.Call) service.createCall();call.setTargetEndpointAddress(new java.net.URL(endpoint));call.setOperationName("方法名");String res=(String)call.invoke(new Object[]{"参数","参数"});System.out.print(res);
  相关解决方案