无法访问Web服务

时间:2011-02-28 10:54:57

标签: java web-services

我正在尝试通过我的java代码访问IIS服务器中托管的Web服务(在C#中),但在响应中获取Read timed Out。以下是WSDL& java代码,我试图通过它来访问这个webservice。我在java代码中提供的URL可以通过浏览器访问。

<?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions name="EncryptService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 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:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
- <wsp:Policy wsu:Id="WSHttpBinding_IEncryptService_policy">
- <wsp:ExactlyOne>
- <wsp:All>
- <sp:SymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
- <wsp:Policy>
- <sp:ProtectionToken>
- <wsp:Policy>
- <sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
- <wsp:Policy>
  <sp:RequireDerivedKeys />
- <sp:BootstrapPolicy>
- <wsp:Policy>
- <sp:SignedParts>
  <sp:Body />
  <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" />
  </sp:SignedParts>
- <sp:EncryptedParts>
  <sp:Body />
  </sp:EncryptedParts>
- <sp:SymmetricBinding>
- <wsp:Policy>
- <sp:ProtectionToken>
- <wsp:Policy>
- <sp:SpnegoContextToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
- <wsp:Policy>
  <sp:RequireDerivedKeys />
  </wsp:Policy>
  </sp:SpnegoContextToken>
  </wsp:Policy>
  </sp:ProtectionToken>
- <sp:AlgorithmSuite>
- <wsp:Policy>
  <sp:Basic256 />
  </wsp:Policy>
  </sp:AlgorithmSuite>
- <sp:Layout>
- <wsp:Policy>
  <sp:Strict />
  </wsp:Policy>
  </sp:Layout>
  <sp:IncludeTimestamp />
  <sp:EncryptSignature />
  <sp:OnlySignEntireHeadersAndBody />
  </wsp:Policy>
  </sp:SymmetricBinding>
- <sp:Wss11>
  <wsp:Policy />
  </sp:Wss11>
- <sp:Trust10>
- <wsp:Policy>
  <sp:MustSupportIssuedTokens />
  <sp:RequireClientEntropy />
  <sp:RequireServerEntropy />
  </wsp:Policy>
  </sp:Trust10>
  </wsp:Policy>
  </sp:BootstrapPolicy>
  </wsp:Policy>
  </sp:SecureConversationToken>
  </wsp:Policy>
  </sp:ProtectionToken>
- <sp:AlgorithmSuite>
- <wsp:Policy>
  <sp:Basic256 />
  </wsp:Policy>
  </sp:AlgorithmSuite>
- <sp:Layout>
- <wsp:Policy>
  <sp:Strict />
  </wsp:Policy>
  </sp:Layout>
  <sp:IncludeTimestamp />
  <sp:EncryptSignature />
  <sp:OnlySignEntireHeadersAndBody />
  </wsp:Policy>
  </sp:SymmetricBinding>
- <sp:Wss11 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <wsp:Policy />
  </sp:Wss11>
- <sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
- <wsp:Policy>
  <sp:MustSupportIssuedTokens />
  <sp:RequireClientEntropy />
  <sp:RequireServerEntropy />
  </wsp:Policy>
  </sp:Trust10>
  <wsaw:UsingAddressing />
  </wsp:All>
  </wsp:ExactlyOne>
  </wsp:Policy>
- <wsp:Policy wsu:Id="WSHttpBinding_IEncryptService_Decrypt_Input_policy">
- <wsp:ExactlyOne>
- <wsp:All>
- <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <sp:Body />
  <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" />
  </sp:SignedParts>
- <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <sp:Body />
  </sp:EncryptedParts>
  </wsp:All>
  </wsp:ExactlyOne>
  </wsp:Policy>
- <wsp:Policy wsu:Id="WSHttpBinding_IEncryptService_Decrypt_output_policy">
- <wsp:ExactlyOne>
- <wsp:All>
- <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <sp:Body />
  <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" />
  </sp:SignedParts>
- <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <sp:Body />
  </sp:EncryptedParts>
  </wsp:All>
  </wsp:ExactlyOne>
  </wsp:Policy>
- <wsp:Policy wsu:Id="WSHttpBinding_IEncryptService_Encrypt_Input_policy">
- <wsp:ExactlyOne>
- <wsp:All>
- <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <sp:Body />
  <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" />
  </sp:SignedParts>
- <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <sp:Body />
  </sp:EncryptedParts>
  </wsp:All>
  </wsp:ExactlyOne>
  </wsp:Policy>
- <wsp:Policy wsu:Id="WSHttpBinding_IEncryptService_Encrypt_output_policy">
- <wsp:ExactlyOne>
- <wsp:All>
- <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <sp:Body />
  <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" />
  <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" />
  </sp:SignedParts>
- <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
  <sp:Body />
  </sp:EncryptedParts>
  </wsp:All>
  </wsp:ExactlyOne>
  </wsp:Policy>
- <wsdl:types>
- <xsd:schema targetNamespace="http://tempuri.org/Imports">
  <xsd:import schemaLocation="http://pinenoil10034.pinelabs.com/EncryptService/service.svc?xsd=xsd0" namespace="http://tempuri.org/" />
  <xsd:import schemaLocation="http://pinenoil10034.pinelabs.com/EncryptService/service.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
  </xsd:schema>
  </wsdl:types>
- <wsdl:message name="IEncryptService_Decrypt_InputMessage">
  <wsdl:part name="parameters" element="tns:Decrypt" />
  </wsdl:message>
- <wsdl:message name="IEncryptService_Decrypt_OutputMessage">
  <wsdl:part name="parameters" element="tns:DecryptResponse" />
  </wsdl:message>
- <wsdl:message name="IEncryptService_Encrypt_InputMessage">
  <wsdl:part name="parameters" element="tns:Encrypt" />
  </wsdl:message>
- <wsdl:message name="IEncryptService_Encrypt_OutputMessage">
  <wsdl:part name="parameters" element="tns:EncryptResponse" />
  </wsdl:message>
- <wsdl:portType name="IEncryptService">
- <wsdl:operation name="Decrypt">
  <wsdl:input wsaw:Action="http://tempuri.org/IEncryptService/Decrypt" message="tns:IEncryptService_Decrypt_InputMessage" />
  <wsdl:output wsaw:Action="http://tempuri.org/IEncryptService/DecryptResponse" message="tns:IEncryptService_Decrypt_OutputMessage" />
  </wsdl:operation>
- <wsdl:operation name="Encrypt">
  <wsdl:input wsaw:Action="http://tempuri.org/IEncryptService/Encrypt" message="tns:IEncryptService_Encrypt_InputMessage" />
  <wsdl:output wsaw:Action="http://tempuri.org/IEncryptService/EncryptResponse" message="tns:IEncryptService_Encrypt_OutputMessage" />
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="WSHttpBinding_IEncryptService" type="tns:IEncryptService">
  <wsp:PolicyReference URI="#WSHttpBinding_IEncryptService_policy" />
  <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="Decrypt">
  <soap12:operation soapAction="http://tempuri.org/IEncryptService/Decrypt" style="document" />
- <wsdl:input>
  <wsp:PolicyReference URI="#WSHttpBinding_IEncryptService_Decrypt_Input_policy" />
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <wsp:PolicyReference URI="#WSHttpBinding_IEncryptService_Decrypt_output_policy" />
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="Encrypt">
  <soap12:operation soapAction="http://tempuri.org/IEncryptService/Encrypt" style="document" />
- <wsdl:input>
  <wsp:PolicyReference URI="#WSHttpBinding_IEncryptService_Encrypt_Input_policy" />
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <wsp:PolicyReference URI="#WSHttpBinding_IEncryptService_Encrypt_output_policy" />
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="EncryptService">
- <wsdl:port name="WSHttpBinding_IEncryptService" binding="tns:WSHttpBinding_IEncryptService">
  <soap12:address location="http://pinenoil10034.pinelabs.com/EncryptService/service.svc" />
- <wsa10:EndpointReference>
  <wsa10:Address>http://pinenoil10034.pinelabs.com/EncryptService/service.svc</wsa10:Address>
- <Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
  <Upn>PINENOIL10034\ASPNET</Upn>
  </Identity>
  </wsa10:EndpointReference>
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

代码:

            EncryptServiceStub stub =new EncryptServiceStub("http://pinenoil10034.pinelabs.com/EncryptService/service.svc");
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, "false");
            //long soTimeout = 300 * 1000; // Five minutes
            //stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
             //  org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);

    //        long soTimeout = 350 * 1000; // Five minutes
            //stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(soTimeout);



            Encrypt encrypt=new Encrypt();

            encrypt.setPlainText("145");
    try{
            EncryptServiceStub.EncryptResponse response=        stub.encrypt(encrypt);
            System.out.println(response.getEncryptResult());
    }
    catch(Exception e){
            e.printStackTrace();
    }

响应是

Unable to sendViaPost to url[http://pinenoil10034.pinelabs.com/EncryptService/service.svc]
java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.io.BufferedInputStream.fill(Unknown Source)
        at java.io.BufferedInputStream.read(Unknown Source)

1 个答案:

答案 0 :(得分:0)

消费者框与托管Web服务的框之间是否有防火墙。