Hi,

So this is my first time creating a web service and I am a bit stuck. This is the code I have used for my web service:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;

[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";
    }

    [WebMethod]
    public string simpleMethod(String str)
    {
        return "Hello " + str;
    }

    [WebMethod]
    public int anotherSimpleMethod(int firstNum, int secondNum)
    {
        return firstNum + secondNum;
    }
}

Now when I go to the URL that I published my web service at http://servername/_vti_bin/mywebservice.asmx I get a page showing my methods, however, when I click on simpleMethod I don't get any text field to insert the value that the web service method receives...any idea what I am doing wrong? (this works fine when I run the web service from Visual Studio)

I followed this guide to publish my web service on the server http://msdn.microsoft.com/en-us/library/ms464040.aspx

What do you guys think? Also I've noticed when I have used other peoples web services that they have a '?wsdl' after the .asmx of their URL, how come mine doesn't? Did I mess up on one of the steps?

Any ideas would be awesome :). Thank You!

Recommended Answers

All 4 Replies

Put the ?wsdl after the .asmx of your webservice. If you get a big xml document, you're on the right track.

Well i have tried putting the ?wsdl after the .asmx of the webservice but I just get the "The WebPage Cannot Found" page. Where should I start debugging this? I went through those instructions on how to publish the web service from Microsoft twice now and I'm still at the same point. Any ideas?

I just tried creating a Windows Forms application to consume the web service but that give a problem too. When I try to add a web reference to the project as the guide I mentioned before says, I get this error:

"The document at the url http://servername/_vti_bin/InfoPathWebService.asmx was not recognized as a known document type. The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; chars"

Any ideas why this would be happening? I followed that guide twice now and this same thing keeps happening.

...service.asmx?wsdl

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.