Navigation

Showing posts with label web service. Show all posts
Showing posts with label web service. Show all posts

Monday, March 09, 2015

How to enable remote access to IIS Express web sites

When developing web services with windows phone applications and using the emulator, Visual Studio provides a rich and integrated development environment.  However, once you move to a physical device, such as a windows phone 8.1 device, for additional testing, you might run into an issue with the device accessing the web service within the IDE.

While you could configure IIS to expose the site you would not have an integrated debugging environment.  However, IIS Express can be configured to expose the IDE website to remote (external) devices.

1.  Turn off or configure windows firewall to allow access to the selected website project port.  You can locate this in the projects properties under web.

image

2.  Navigate to the IIS Express applicationhost.config file. (%HOMEPATH%\Documents\IISExpress\config\applicationhost.config)

3. Find the website you working with (search for the configured port) and add the highlighted line changing localhost to the local ip address that the remote device will use to access the web site.

image

4.  Make sure that you run Visual Studio as an administrator.

Friday, December 03, 2010

How to use IIS Compression with Web Services

Using IIS compression with web services is a simple way to provide better performance for your services.  This article will detail implementing this solution in IIS6 and IIS7.

First, you need to ensure that the web service proxy in your application has the following property set to true;

Dim myService as new localhost.service1
myService.EnableDecompression = True

This will ensure that your application takes advantage of the compression.

 

Second, you need to configure IIS compression on your server.  To do this ensure that you have the following installed;image

Then turn compression on in the IIS management console;

image

Then create a bat file in C:\inetpub\AdminScripts and place the following lines of code into the bat file;

IISreset.exe /stop
cscript.exe adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript.exe adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "ashx"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"
IISreset.exe /restart

This will enable compression on your web service.

The following tool is a easy free application that allows you to compare the difference in your application communication between compressed and uncompressed communications of xml data.

http://devolutions.net/products/TCP-Spy-Net.aspx

image

Friday, June 25, 2010

Access WCF Service by WEBGet from Browser

If you want to expose a simple web service (WCF) so that it can be accessed by a web get or browser you need to first insure that the input and output are simple data types like strings or integers.

1.Create the web site project

2.  Add a reference to System.ServiceModel.Web (so we can access the WebGet decleration.

3.  Add your function and decerate it with the following;

<OperationContract()> _
    <WebGet()> _
    Function Dosmothing(ByVal pValue As String) As String




4.  Add the following to your web.config file;



 <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>


 



5.  Update your service model to reflect the one below. 



<system.serviceModel>
<behaviors>
   <endpointBehaviors>
    <behavior name="NewBehavior">
     <webHttp />
    </behavior>
   </endpointBehaviors>
   <serviceBehaviors>
    <behavior name="my.Application.Behavior1">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
<services>
   <service behaviorConfiguration="Behavior1"
    name="myInterface">
    <endpoint behaviorConfiguration="NewBehavior" binding="webHttpBinding"
     bindingConfiguration="" contract="myInterface" />
   </service>
  </services>
</system.serviceModel>


6.Now you can access the function like this;


http://localhost:54433/myInterface.svc/DoSmothing?pValue=Smothing