我通过AXIS2 通过WSDL的方式调用 C# web services 代码如下:public static void main(String args[]){
try {
TasksServiceStub tss = new TasksServiceStub("http://10.0.0.133:8731/");
tss._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
TasksServiceStub.CheckOper co = new TasksServiceStub.CheckOper();
co.setOperId("5001");
co.setPassword("303030");
co.setGroupids("");
co.setName("");
co.setStarlevel("");
co.setTeam("");
try {
TasksServiceStub.CheckOperResponse cor = tss.checkOper(co);
int a = cor.getCheckOperResult();
System.out.println(a);
System.out.println(cor.getGroupids()+cor.getStarlevel()+cor.getTeam());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
tss.cleanup();
}
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}org.apache.axis2.AxisFault: Connection reset; nested exception is: 
java.net.SocketException: Connection reset; nested exception is: 
org.apache.axis2.AxisFault: Connection reset; nested exception is: 
java.net.SocketException: Connection reset
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:227)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:674)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:237)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:202)
at org.tempuri.TasksServiceStub.checkOper(TasksServiceStub.java:1817)
at test.wcf.client.TextXFileClient.main(TextXFileClient.java:24)
Caused by: org.apache.axis2.AxisFault: Connection reset; nested exception is: 
java.net.SocketException: Connection reset
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:344)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:204)
... 5 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:541)
at org.apache.axis2.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:119)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:335)
... 6 more是什么原因导致的啊,麻烦高手帮忙看看。

解决方案 »

  1.   

    java.net.SocketException: Connection reset
    不能连接嘛,检查下调用的地址是否正确,或者c#的webservice是否开发,是否有权限控制等
      

  2.   

    web services 没有问题 C#的客户端是可以调用的wsdl如下:  <?xml version="1.0" encoding="utf-8" ?> 
    - <wsdl:definitions name="TasksService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
    - <wsp:Policy wsu:Id="WSHttpBinding_ITasksService_policy">
    - <wsp:ExactlyOne>
    - <wsp:All>
    - <wsrm:RMAssertion xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
      <wsrm:InactivityTimeout Milliseconds="600000" /> 
      <wsrm:AcknowledgementInterval Milliseconds="200" /> 
      </wsrm:RMAssertion>
      <wsaw:UsingAddressing /> 
      </wsp:All>
      </wsp:ExactlyOne>
      </wsp:Policy>
    - <wsdl:types>
    - <xsd:schema targetNamespace="http://tempuri.org/Imports">
      <xsd:import schemaLocation="http://10.0.0.133:8731/?xsd=xsd0" namespace="http://tempuri.org/" /> 
      <xsd:import schemaLocation="http://10.0.0.133:8731/?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
      <xsd:import schemaLocation="http://10.0.0.133:8731/?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/EngineWCFService" /> 
      <xsd:import schemaLocation="http://10.0.0.133:8731/?xsd=xsd3" namespace="http://schemas.datacontract.org/2004/07/System.Collections.Generic" /> 
      <xsd:import schemaLocation="http://10.0.0.133:8731/?xsd=xsd4" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" /> 
      </xsd:schema>
      </wsdl:types>
    - <wsdl:message name="ITasksService_DoWork_InputMessage">
      <wsdl:part name="parameters" element="tns:DoWork" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_DoWork_OutputMessage">
      <wsdl:part name="parameters" element="tns:DoWorkResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_getTask_InputMessage">
      <wsdl:part name="parameters" element="tns:getTask" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_getTask_OutputMessage">
      <wsdl:part name="parameters" element="tns:getTaskResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_submitResult_InputMessage">
      <wsdl:part name="parameters" element="tns:submitResult" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_submitResult_OutputMessage">
      <wsdl:part name="parameters" element="tns:submitResultResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_checkOper_InputMessage">
      <wsdl:part name="parameters" element="tns:checkOper" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_checkOper_OutputMessage">
      <wsdl:part name="parameters" element="tns:checkOperResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_pauseOper_InputMessage">
      <wsdl:part name="parameters" element="tns:pauseOper" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_pauseOper_OutputMessage">
      <wsdl:part name="parameters" element="tns:pauseOperResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_restartOper_InputMessage">
      <wsdl:part name="parameters" element="tns:restartOper" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_restartOper_OutputMessage">
      <wsdl:part name="parameters" element="tns:restartOperResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_exitOper_InputMessage">
      <wsdl:part name="parameters" element="tns:exitOper" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_exitOper_OutputMessage">
      <wsdl:part name="parameters" element="tns:exitOperResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_workMoveBack_InputMessage">
      <wsdl:part name="parameters" element="tns:workMoveBack" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_workMoveBack_OutputMessage">
      <wsdl:part name="parameters" element="tns:workMoveBackResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_AppDelay_InputMessage">
      <wsdl:part name="parameters" element="tns:AppDelay" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_AppDelay_OutputMessage">
      <wsdl:part name="parameters" element="tns:AppDelayResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_UpdateRecoveryTime_InputMessage">
      <wsdl:part name="parameters" element="tns:UpdateRecoveryTime" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_UpdateRecoveryTime_OutputMessage">
      <wsdl:part name="parameters" element="tns:UpdateRecoveryTimeResponse" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_GetImage_InputMessage">
      <wsdl:part name="parameters" element="tns:GetImage" /> 
      </wsdl:message>
    - <wsdl:message name="ITasksService_GetImage_OutputMessage">
      <wsdl:part name="parameters" element="tns:GetImageResponse" /> 
      </wsdl:message>
      

  3.   


    - <wsdl:portType name="ITasksService">
    - <wsdl:operation name="DoWork">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/DoWork" message="tns:ITasksService_DoWork_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/DoWorkResponse" message="tns:ITasksService_DoWork_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="getTask">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/getTask" message="tns:ITasksService_getTask_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/getTaskResponse" message="tns:ITasksService_getTask_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="submitResult">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/submitResult" message="tns:ITasksService_submitResult_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/submitResultResponse" message="tns:ITasksService_submitResult_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="checkOper">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/checkOper" message="tns:ITasksService_checkOper_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/checkOperResponse" message="tns:ITasksService_checkOper_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="pauseOper">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/pauseOper" message="tns:ITasksService_pauseOper_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/pauseOperResponse" message="tns:ITasksService_pauseOper_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="restartOper">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/restartOper" message="tns:ITasksService_restartOper_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/restartOperResponse" message="tns:ITasksService_restartOper_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="exitOper">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/exitOper" message="tns:ITasksService_exitOper_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/exitOperResponse" message="tns:ITasksService_exitOper_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="workMoveBack">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/workMoveBack" message="tns:ITasksService_workMoveBack_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/workMoveBackResponse" message="tns:ITasksService_workMoveBack_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="AppDelay">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/AppDelay" message="tns:ITasksService_AppDelay_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/AppDelayResponse" message="tns:ITasksService_AppDelay_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="UpdateRecoveryTime">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/UpdateRecoveryTime" message="tns:ITasksService_UpdateRecoveryTime_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/UpdateRecoveryTimeResponse" message="tns:ITasksService_UpdateRecoveryTime_OutputMessage" /> 
      </wsdl:operation>
    - <wsdl:operation name="GetImage">
      <wsdl:input wsaw:Action="http://tempuri.org/ITasksService/GetImage" message="tns:ITasksService_GetImage_InputMessage" /> 
      <wsdl:output wsaw:Action="http://tempuri.org/ITasksService/GetImageResponse" message="tns:ITasksService_GetImage_OutputMessage" /> 
      </wsdl:operation>
      </wsdl:portType>
    - <wsdl:binding name="WSHttpBinding_ITasksService" type="tns:ITasksService">
      <wsp:PolicyReference URI="#WSHttpBinding_ITasksService_policy" /> 
      <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    - <wsdl:operation name="DoWork">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/DoWork" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="getTask">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/getTask" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="submitResult">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/submitResult" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="checkOper">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/checkOper" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="pauseOper">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/pauseOper" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="restartOper">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/restartOper" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="exitOper">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/exitOper" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="workMoveBack">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/workMoveBack" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="AppDelay">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/AppDelay" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="UpdateRecoveryTime">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/UpdateRecoveryTime" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="GetImage">
      <soap12:operation soapAction="http://tempuri.org/ITasksService/GetImage" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:service name="TasksService">
    - <wsdl:port name="WSHttpBinding_ITasksService" binding="tns:WSHttpBinding_ITasksService">
      <soap12:address location="http://10.0.0.133:8731/" /> 
    - <wsa10:EndpointReference>
      <wsa10:Address>http://10.0.0.133:8731/</wsa10:Address> 
    - <Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
      <Dns>localhost</Dns> 
      </Identity>
      </wsa10:EndpointReference>
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>
      

  4.   

    通过http://10.0.0.133:8731/可以访问到WSDL,但其它的不行啊。问题应该就在TasksServiceStub tss = new TasksServiceStub("http://10.0.0.133:8731/"); 这个参数ENDPOINT应该是什么?