سؤال

I have a Windows CE project in Visual Studio 2008. There are multiple Web References to services hosted in IIS 6.0 on a Windows Server 2003. When I debug the app or run after it is deployed I am unable to consume the web services due to the following WebException:

Message: "Could not establish connection to network."

Response: Nothing

Status: System.Net.WebExceptionStatus.ConnectFailure

StackTrace: " at System.Net.HttpWebRequest.finishGetResponse() at System.Net.HttpWebRequest.GetResponse() at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at WMS4.Tests.TestService.GetData() ...

I have created a test service to test the behavior. This service simply returns the string "Success". Here is the service modal section of the app.config from the WCF Service Library that contains the test service. Other services have been omitted:

 <system.serviceModel>
    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="http://*myserver*"/>
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <services>    
      <service name="WMSDataService.TestService">
        <endpoint address="" binding="basicHttpBinding" contract="WMSDataService.ITestService"></endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />       
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicConfig">
          <security mode="None">
          </security>
        </binding>
      </basicHttpBinding>     
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="basicBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>       
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

As this is a Windows CE project there is no client app.config file.

Now, there are production devices that are consuming the same services without the exception. I am also able to consume the service from a test Console client. It appears that only the new mobile device I am testing with is affected by this.

I feel like this is a proxy authentication issue, but I do not see any problems with the proxy in the Reference file. So, what can I do to eliminate this exception and consume the service?

هل كانت مفيدة؟

المحلول

For future generations:

I was unable to figure out why only the new device was unable to consume the services (see error details above). Tests from a console and existing production devices all consumed the services without any problem.

To fix the issue I put an absolute address for each endpoint instead of the relative address, as below:

<system.serviceModel>   
    <services>
      <service name="WMSDataService.TestService">
        <endpoint address="http://*MyServerURL*/WMSDataService.TestService.svc" binding="basicHttpBinding" contract="WMSDataService.ITestService" />
          </service>   
      </services> 
  </system.serviceModel>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top