Monday, December 10, 2012

WCF service calls works properly in Intranet, but not in internet

WCF service calls works properly in Intranet, but not in internet

I've been working with silverlight application for over a month now, and have stumbled upon a weird issue. I have a WCF service running in IIS, accessible from the URL : https://xyztestname.com/service1.svc

I am able to consume this in visual studio and when deployed from visual studio, am able to get proper call backs from WCF service and everything works fine. When i deploy the package files in to the same folder as the Service1.svc in IIS, the WCF service is not hitting properly.

Please help me resolve this issue :(! Here is my web.config file.

<?xml version="1.0"?> <!--   For more information on how to configure your ASP.NET application, please visit  http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> <customErrors mode="Off"/> </system.web> <system.serviceModel> <bindings> <basicHttpBinding>  <binding name="BasicHttpEndpointBinding">  <security mode="TransportCredentialOnly">  <transport clientCredentialType="None" /> </security> </binding> </basicHttpBinding> </bindings> <services> <service name="InformationService.Service1"> <endpoint address="" binding="basicHttpBinding"     bindingConfiguration="BasicHttpEndpointBinding" name="BasicHttpEndpoint" contract="InformationService.IService1">     </endpoint>     </service> </services> <behaviors> <serviceBehaviors> <behavior name="">  <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> </configuration> 

I dont know where i am going wrong. But the same Virtual folder when accessed through intranet works fine, but doesn't work when accessed through internet :( Please help.

Edit: After checking into the client config, i found out that Visual studio automatically resolved the URL into an intranet URL. When i changed back to the internet URL, i am getting an exception thrown.

n error occurred while trying to make a request to URI 'https://xyztestname.com/Service1.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.

However, I have copied both the crossdomain and clientaccesspolicy files into the root of the application in IIS. :( Please help.

Answers & Comments...

Answer: 1

You have to deploy your application to the specific ip and port to be able to use it in internet. I think you can.

To do this you need to edit applicationhost.config file manually (edit bindingInformation '::')

To start iisexpress, you need administrator privileges

1 – Bind your application to your public IP address 

Normally when you run an application in IIS Express, it's only accessible on http://localhost:[someport]. In order to access it from another machine, it needs to be bound to your public IP address as well. Open D:\Users[YourName]\Documents\IISExpress\config\applicationhost.config and find your site. You will find something like this:

 <site name="YOUR PROJECT NAME HERE" id="2">      <application path="/">       <virtualDirectory path="/" physicalPath="YOUR PHYSICAL PATH HERE"              <binding protocol="http" bindingInformation="*:58938:localhost" />     </bindings> </site>  

In , add another row:

   <binding protocol="http" bindingInformation="*:58938:192.168.1.42" />  

(But with your IP, and port number, of course)

    2 - Allow incoming connections 

If you're running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.42:58938 with whatever IP and port you are using:

netsh http add urlacl url=http://192.168.1.42:58938/ user=everyone

This just tells http.sys that it's ok to talk to this url.

netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=58938 profile=private remoteip=localsubnet action=allow

This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.

And there you go, you can now press Ctrl-F5 in Visual Studio, and browse you site from another computer!

by : Bhushan Firakehttp://stackoverflow.com/users/1844389




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog