locked
Unable to access my Web Service on remote pc RRS feed

  • Question

  • User-438408541 posted
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    
    public class Service : System.Web.Services.WebService
    {
        public Service () {
    
            //Uncomment the following line if using designed components 
            //InitializeComponent(); 
        }
    
        [WebMethod]
        public string HelloWorld() {
            return "Hello World";
        }
        
    }

    And I am using Web.config file...

    <?xml version="1.0"?>
    <!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\vx.x\Config
    -->
    <configuration>
    <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    </sectionGroup>
    </sectionGroup>
    </sectionGroup>
    </configSections>
    <appSettings/>
    <connectionStrings/>
    <system.web>
    <!--
    Set compilation debug="true" to insert debugging
    symbols into the compiled page. Because this
    affects performance, set this value to true only
    during development.
    -->
    <webServices>
    <protocols>
    <add name="HttpSoap12"/>
    <add name="HttpSoap"/>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
    </protocols>
    </webServices>
    <compilation debug="true">
    <assemblies>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    </assemblies>
    </compilation>
    <!--
    The <authentication> section enables configuration
    of the security authentication mode used by
    ASP.NET to identify an incoming user.
    -->
    <authentication mode="Windows"/>
    <!--
    The <customErrors> section enables configuration
    of what to do if/when an unhandled error occurs
    during the execution of a request. Specifically,
    it enables developers to configure html error pages
    to be displayed in place of a error stack trace.

    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
    <error statusCode="403" redirect="NoAccess.htm" />
    <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>
    -->
    <pages>
    <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </controls>
    </pages>
    <httpHandlers>
    <remove verb="*" path="*.asmx"/>
    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
    </httpHandlers>
    <httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>
    </system.web>
    <system.codedom>
    <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="WarnAsError" value="false"/>
    </compiler>
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/>
    </compiler>
    </compilers>
    </system.codedom>
    <!--
    The system.webServer section is required for running ASP.NET AJAX under Internet
    Information Services 7.0. It is not necessary for previous version of IIS.
    -->
    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
    <remove name="ScriptModule"/>
    <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </modules>
    <handlers>
    <remove name="WebServiceHandlerFactory-Integrated"/>
    <remove name="ScriptHandlerFactory"/>
    <remove name="ScriptHandlerFactoryAppServices"/>
    <remove name="ScriptResource"/>
    <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </handlers>
    </system.webServer>
    <runtime>
    <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>

    I am having problem to access this webservice on remote pc with ip address 192.168.0.3

    i am trrying to add a web refernce in url i am trying http://l192.168.0.2:1298/WebService3/Service.asmx

    the server on which i am using as webserver is having two lan adapters 

    one for internet(Modem) and another for sharing(ip address :192.168.0.2)

    and i use my laptop to use the web service...both pc and laptop has same version of visual studio 2010 

    i have enabled http in firewall...and once i tried by completely shuting down firewall

    but still i cant access my webservice from 192.168.0.3(laptop)

    i tried to access http://localhost:1298/WebService3/Service.asmx its working fine on my pc but when i try to replace with http://192.168.0.2:1298/WebService3/Service.asmx it wont work.

    but trying this work http://127.0.0.1:1298/WebService3/Service.asmx

    what is problem...i want to access my webservice from laptop 

    please help me thanks in advance

    Sunday, January 13, 2013 2:19 AM

All replies

  • User1546878023 posted

    The way you are running it (through Visual Studio) it does not use port 80, but instead, as you can see in the url, it goes through on port 1298. Depending on your setup this may be causing you some problems. Also if you are using the built-in Cassini webserver it does not allow remote connections at all


    Try setting up the IIS and expose the webservice on port 80 instead and see if that is working better?

    Sunday, January 13, 2013 5:11 AM
  • User-182667613 posted

    Hi,

    before deploying the web service in the http server just try with the IIS server. If it is working fine with your IIS server just give the reference of your IIS server to the http server and it will work fine.

    Fore more reference go through the following links:--

    http://www.codeproject.com/Articles/863/Your-first-C-Web-Service
    http://forums.asp.net/t/1263452.aspx/1
    http://social.msdn.microsoft.com/Forums/pl-PL/asmxandxml/thread/f9b6b665-cf50-4b18-92e1-487fb1f91c1c
    http://www.codeproject.com/Questions/302344/How-to-deploy-a-web-service-in-IIS
    
    Let me know if it works..


    Sunday, January 13, 2013 5:22 AM
  • User-438408541 posted

    I tried to change port by 

    setting Use Dynaimic Port to false

    and Now changing port to port number 80

    but when i try to run web service it does not start

    Server Error in Application "DEFAULT WEB SITE"

    Internet Information Services 7.5

    <fieldset><legend>Error Summary</legend>

    HTTP Error 500.24 - Internal Server Error

    An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

    </fieldset>
    <fieldset><legend>Detailed Error Information</legend>
    Module ConfigurationValidationModule
    Notification BeginRequest
    Handler WebServiceHandlerFactory-Integrated
    Error Code 0x80070032
    Requested URL http://localhost:80/WebService3/Service.asmx
    Physical Path C:\inetpub\wwwroot\WebService3\Service.asmx
    Logon Method Not yet determined
    Logon User Not yet determined
    </fieldset>
    <fieldset><legend>Most likely causes:</legend>
    • system.web/identity@impersonate is set to true.
    </fieldset>
    <fieldset><legend>Things you can try:</legend>
    • If the application supports it, disable client impersonation.
    • If you are certain that it is OK to ignore this error, it can be disabled by setting system.webServer/validation@validateIntegratedModeConfiguration to false.
    • Move this application to an application pool using Classic .NET mode - for example, %SystemRoot%\system32\inetsrv\appcmd set app "Default Web Site/" /applicationPool:"Classic .NET AppPool"
    (You can set "Classic .NET AppPool" to the name of another application pool running in Classic managed pipeline mode)</fieldset>
    <fieldset><legend>Links and More Information</legend>If you are not sure or unable to use the first two options, then it is preferred that you move this application to Classic mode.

    View more information »

    </fieldset>

     I tried to run this command on cmd prompt it says 

    C:\Users\Ankur>%SystemRoot%\system32\inetsrv\appcmd set app "Default Web Site/"
    /applicationPool:"Classic .NET AppPool"
    ERROR ( message:Configuration error
    Filename: redirection.config
    Line Number: 0
    Description: Cannot read configuration file due to insufficient permissions
    . )

    How to fix it 

    I dont much about IIS i am just new Webservice devloper 

    I want to know that to access web service there is one way to access web services remotely is through IIS or we can just go to any other PC on network just Open new project and just add a web refence (but in my case i am unable to access it....)

    please help me .....

    Sunday, January 13, 2013 6:46 AM
  • User433674817 posted

    For your earlier question:

    Please try using the below configuration file:

     

    <?xml version="1.0"?>

    <!--

    Note: As an alternative to hand editing this file you can use the

     web admin tool to configure settings for your application. Use

     the Website->Asp.Net Configuration option in Visual Studio.

     A full list of settings and comments can be found in

     machine.config.comments usually located in

     \Windows\Microsoft.Net\Framework\vx.x\Config

     -->

    <configuration>

      <configSections>

        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

          <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

            <!--<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>      

              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>

              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

              <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>-->

            </sectionGroup>

          </sectionGroup>

        </sectionGroup>

      </configSections>

      <appSettings/>

      <connectionStrings/>

      <system.web>

        <!--

    Set compilation debug="true" to insert debugging

     symbols into the compiled page. Because this

     affects performance, set this value to true only

     during development.

     -->

        <webServices>

          <protocols>

            <add name="HttpSoap12"/>

            <add name="HttpSoap"/>

            <add name="HttpGet"/>

            <add name="HttpPost"/>

          </protocols>

        </webServices>

        <compilation debug="true">

          <assemblies>

            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

          </assemblies>

        </compilation>

        <!--

    The <authentication> section enables configuration

     of the security authentication mode used by

     ASP.NET to identify an incoming user.

     -->

        <authentication mode="Windows"/>

        <!--

    The <customErrors> section enables configuration

     of what to do if/when an unhandled error occurs

     during the execution of a request. Specifically,

     it enables developers to configure html error pages

     to be displayed in place of a error stack trace.

     

    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

     <error statusCode="403" redirect="NoAccess.htm" />

     <error statusCode="404" redirect="FileNotFound.htm" />

     </customErrors>

     -->

        <pages>

          <controls>

            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

          </controls>

        </pages>

        <httpHandlers>

          <remove verb="*" path="*.asmx"/>

          <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

          <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

          <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>

        </httpHandlers>

        <httpModules>

          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        </httpModules>

      </system.web>

      <system.codedom>

        <compilers>

          <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

            <providerOption name="CompilerVersion" value="v3.5"/>

            <providerOption name="WarnAsError" value="false"/>

          </compiler>

          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

            <providerOption name="CompilerVersion" value="v3.5"/>

            <providerOption name="OptionInfer" value="true"/>

            <providerOption name="WarnAsError" value="false"/>

          </compiler>

        </compilers>

      </system.codedom>

      <!--

    The system.webServer section is required for running ASP.NET AJAX under Internet

     Information Services 7.0. It is not necessary for previous version of IIS.

     -->

      <system.webServer>

        <validation validateIntegratedModeConfiguration="false"/>

        <modules>

          <remove name="ScriptModule"/>

          <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        </modules>

        <handlers>

          <remove name="WebServiceHandlerFactory-Integrated"/>

          <remove name="ScriptHandlerFactory"/>

          <remove name="ScriptHandlerFactoryAppServices"/>

          <remove name="ScriptResource"/>

          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

          <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

          <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

        </handlers>

      </system.webServer>

      <runtime>

        <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">

          <dependentAssembly>

            <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>

            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

          </dependentAssembly>

          <dependentAssembly>

            <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>

            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

          </dependentAssembly>

        </assemblyBinding>

      </runtime>

    </configuration>

    Also, please check if the laptop and the server on the same domain, if not make sure that trust relationship between two exists.

    Also for the latest error, please change the Application pool Managed Pipeline mode to Classic mode.

    I hope this helps

    Wednesday, February 20, 2013 4:53 PM