【问题标题】:Unable to access webservice无法访问网络服务
【发布时间】:2011-02-28 10:54:57
【问题描述】:

我正在尝试通过我的 java 代码访问托管在 IIS 服务器中的 web 服务(在 C# 中),但响应中读取超时。以下是我试图访问此 web 服务的 WSDL 和 java 代码。我的 URL我在我的 java 代码中提供的可以通过浏览器访问。

<?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)

【问题讨论】:

  • 我在pinenoil10034.pinelabs.com 上收到 404 - 你确定子域是正确的吗?
  • 此网址不公开。我们可以通过局域网访问它。
  • 您的浏览器是否使用 HTTP 代理?你能从服务器获取这个 URL 吗?

标签: java web-services


【解决方案1】:

消费者盒子和托管网络服务的盒子之间是否有防火墙。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-16
    • 2019-08-04
    • 2016-10-01
    • 1970-01-01
    • 2016-01-01
    • 2012-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多