1

I am working on a c# soap web service. The web service is used by other C# windows programs as well as PHP web pages. I need to pass a paramater in the url of the web service that the c# windows programs or the php scripts use to connect to the web service. I was thing of being able to do something like:

http://MyWebService.asmx?myParam=true&myOtherParam=false

If I used the method above how would I go about getting the paramaters that are in the URL from the c# web service.

Thanks for any help you can provide.

4
  • Can't you read them from Request.QueryString? Commented Nov 2, 2011 at 13:08
  • I did try that but not sure what the namespace was, I did look it up but it only seemed to be available for ASP.net pages Commented Nov 2, 2011 at 13:16
  • It is in System.Web namespace. You can access it like HttpContext.Current.Request.QueryString Commented Nov 2, 2011 at 13:27
  • @Suhas yes you are right. Cheers for that Commented Nov 2, 2011 at 14:01

3 Answers 3

4

If you're going to call it this way, the parameter names should match those expected by the webservice. You also need to include your method name, e.g.:

http://MyWebService.asmx/MyMethodName?myParam=true&myOtherParam=false
Sign up to request clarification or add additional context in comments.

4 Comments

When you say the method name, could this be the name of the constructor that is used when the service is first used.
Do you not have a method (function) in your web service decorated with the [WebMethod] attribute?
Yea I do, but I thought it would be simpler to set variables from the parameters in a constructor then modifying several methods which is what I would need to do
Whichever method you want to call (the one that has that attribute) should be specified in your URL.
4

I would recommend looking at Restful WCF.

Your service contract will look something like this:

[ServiceContract]
public interface IYourService
{
    [OperationContract, WebInvoke(Method = "GET", UriTemplate = "YourMethod?myParam={myParam}&myOtherParam={myOtherParam}")]
    void YourMethod(bool myParam, bool myOtherParam) {...}
}

Comments

2

You can access them in QueryString. To access the query string use HttpContext.Current.Request.QueryString

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.