2 Replies - 1208 Views - Last Post: 31 July 2014 - 05:28 AM Rate Topic: -----

#1 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 31
  • Joined: 07-July 14

Noob: Simple ASP.NET Web Service

Posted 30 July 2014 - 07:11 AM

Hi Guys, I've been learning how to consume a web service, and that has been a lot of fun. Now I'm working on learning how to create a webservice for consumption.

I created an empty web application project
I added a Web Service
Everything works locally when I debug.

This a simple "Hello World" and "TempConvert" type API... you know, the samples they use at MSDN, etc..

When I FTP this to my server, I get a parse error.

Here is the asmx markup:

<%@ WebService Language="vb" CodeBehind="~/App_Code/WebService.vb" Class="WebServiceDemo.WebService" %>


I had to manually create the App_Code/WebService.vb file because it wasn't FTP'ing any *.vb files. I have the project set to "publish all files in project folder".. but..

here is the vb file:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://foo-derp.com/Service/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class WebService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As String
        Return "Hello World"
    End Function

    <WebMethod()> Public Function FahrenheitToCelsius(ByVal Fahrenheit As String) As String
        Dim fahr
        fahr = Trim(Replace(Fahrenheit, ",", "."))
        If fahr = "" Or IsNumeric(fahr) = False Then Return "Error"
        Return ((((fahr) - 32) / 9) * 5)
    End Function

    <WebMethod()> Public Function CelsiusToFahrenheit(ByVal Celsius As String) As String
        Dim cel
        cel = Trim(Replace(Celsius, ",", "."))
        If cel = "" Or IsNumeric(cel) = False Then Return "Error"
        Return ((((cel) * 9) / 5) + 32)
    End Function



End Class




When I try to navigate to my *asmx file, i get this error:

Parser Error Message: Could not create type 'WebService'.

Source Error:


Line 1:  <%@ WebService Language="vb" CodeBehind="~/App_Code/WebService.vb" Class="WebService" %>


Source File: /Service/WebServiceASMX.asmx    Line: 1 



Any ideas what could be the problem?

This post has been edited by modi123_1: 30 July 2014 - 07:18 AM
Reason for edit:: always double check your posts..


Is This A Good Question/Topic? 0
  • +

Replies To: Noob: Simple ASP.NET Web Service

#2 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 31
  • Joined: 07-July 14

Re: Noob: Simple ASP.NET Web Service

Posted 30 July 2014 - 07:16 AM

Also, this is my web.config

<?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" strict="false" explicit="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5"  />
      <customErrors mode="Off"/>
    </system.web>
</configuration>


Was This Post Helpful? 0
  • +
  • -

#3 stevenryals  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 31
  • Joined: 07-July 14

Re: Noob: Simple ASP.NET Web Service

Posted 31 July 2014 - 05:28 AM

Seems to be a perplexing issue to the forum as well...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1