开发者

"Unable to connect to the remote server"

开发者 https://www.devze.com 2022-12-12 06:30 出处:网络
I\'m able to call a 3rd party vendor\'s web service from a Windows form program just fine. When I try to call the same web service and web method and same URL from a WCF web service I get the followin

I'm able to call a 3rd party vendor's web service from a Windows form program just fine. When I try to call the same web service and web method and same URL from a WCF web service I get the following error:

ExportValuationPolicyNumber:Exception=System.Net.WebException: Unable to connect to the remote server ---> 
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly 
respond after a period of time, or established connection failed 
because connected host has failed to respond 66.77.241.76:80

   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream()
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at TFBIC.RCT.WCFWebServices.ExpressLync.ValuationServiceWse.ExportValuationPolicyNumber(String PolicyNumber) in c:\Source\TFBIC.RCT.WCFWebServices\TFBIC.RCT.WCFWebServices\Web References\ExpressLync\Reference.cs:line 519
   at TFBIC.RCT.WCFWebServices.ValuationService.ExportValuationPolicyNumber(String PolicyNumber) in c:\Source\TFBIC.RCT.WCFWebServices\TFBIC.RCT.WCFWebServices\ValuationService.svc.cs:line 97

I'm basically trying to write a WCF wrapper for the vendor .asmx/WSE3 service. Let's not get off point - but Microsoft says WCF can call WSE3, but only with SSL turned on, and my vendor - believe it or not - is not allowing SSL connection. So I'mn stuck writing the wrapper so I can call from BizTalk 2009. Right now, I'm testing the wrapper via a Console program.

What can I even do to debug? I've added EventLog traces before and after the WCF service where it calls the .asmx service - so I know that's where it's blowing (plus the line number in the error above).

I have the following in my web.config:

<microsoft.web.services3>
        <diagnostics>
                <trace enabled="true" 
                           input="c:\inetpub\wwwroot\wsetraces\InputTrace.webinfo" 
                           output="c:\inetpub\wwwroot\wsetraces\OutputTrace.webinfo" />
                <detailedErrors enabled="true"开发者_如何学运维 />
        </diagnostics>
</microsoft.web.services3>

and I have given the directory full-access to everyone - yet no trace appears there.

What are some things I can look for or try next to debug this?

In theory "ping" results should not matter, because the website is working from the Windows form program that calls it just fine.

Nevertheless - here is what Ping shows and it looks a little questionable to me:

C:\Users\uxnxw01>ping rct.msbexpress.net

Pinging rct.msbexpress.net [66.77.241.56] with 32 bytes of data:
Reply from 10.193.99.5: Destination net unreachable.
Reply from 10.193.99.5: Destination net unreachable.
Request timed out.
Reply from 10.193.99.5: Destination net unreachable.

Ping statistics for 66.77.241.56:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),

Thanks,

Neal Walters


WireShark analysis

I did run Wireshark - posted some results in comment below. However, after reading it more, it does not always say "Destination Unreachable". But in the case where it's failing, I never get any databack. I'm still confused what to do next. I have been comparing packets but it's slow and confusing. For instance, I still haven't found the key (a specific policyNum) that I am passing in the request packet. I also see a few "Destination Unreachable" statements in the one that worked.

In the one that works, I never see 66.77.241.76, I only see our company's proxy. But I can't see anything in the config (or code) that would tell WSE3 to use or not use the proxy.


Telnet results:

C:\Users\uxnxw01>telnet 66.77.241.56 80
Connecting To 66.77.241.56...Could not open connection to the host, on port 80:
Connect failed

C:\Users\uxnxw01>telnet 66.77.241.76 80
Connecting To 66.77.241.76...Could not open connection to the host, on port 80:
Connect failed

I'm not sure what this proves. Like I said, I CAN definitely call the same webservice from a Windows form by directly calling its WSE3 interface. I know that I can get there that way.

I'm thinking the main differences in the two programs is that one is running under a Win Form and calling WSE3 directly. That one works. The one that fails is basically 99% same code, published as a WCF service, so it's running under IIS (then a console program calls the WCF/IIS service on my machine, which in turns calls the WSE3 service).

Is there some reason IIS wouldn't use the same proxy?


Thanks to all the help above - but here's the real answer:

valservice.Proxy = new System.Net.WebProxy("http://10.192.xx.xx:8080", true);

The WCF service running under IIS was apparently NOT using the same proxy, so I set it manually in the code. I'll post another question to see if there is a way to do this in config file.


You may wish to use Wireshark to see what's going on with the network traffic.


Ping requests (ICMP packets) may be disabled on the firewall. So it's perfectly possible to not get a ping response back, whilst being able to access the box on different ports.

Try and use telnet to connect to 66.77.241.56 on port 80 and see if you get a response.

telnet 66.77.241.56 80

Alternatively, a tracerte to said IP address may provide some more detailed information for one of your network admins, as it could equally have to do with network routing or NAT.

Third possibility is that you may need to explicitly set the Proxy property on your SoapHttpClientProtocol SOAP client instance. WinForms pick this up automatically, but from a web service/app this is not the case.


See my comments on other people's posts too, but in addition, related to your diagnostic log, this is the XML that I have in my config to dump a WCF trace log:

<configuration>

    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
                <listeners>
                    <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "MyService.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>

</configuration>
0

精彩评论

暂无评论...
验证码 换一张
取 消