prestomanifesto
prestomanifesto

Reputation: 12796

Passing a Complex Type as a Parameter to an ASMX Service

I am trying to write a simple ASMX web service in C#. For the life of me, I can't understand or find out how to accept more complex parameters than primitives.

Is it possible to do something like:

[WebMethod]
public string MyMethod(SomeStruct parameter)
{
}

Upvotes: 2

Views: 4903

Answers (2)

Clemsouz
Clemsouz

Reputation: 321

try this :

[WebMethod]
public string MyMethod( )
{
   var parameter = new JavaScriptSerializer().Deserialize<SomeStruct>(HttpContext.Current.Request["parameter"]);
}

Upvotes: 0

prestomanifesto
prestomanifesto

Reputation: 12796

For anyone else having the same question. The answer was to use Soap.

As to why use ASMX service instead of WCF, there are a couple reasons:

  1. Easier to configure and deploy for a small web service
  2. Other developers are using and expect ASMX services

While the first reason is arguable, there really is nothing that can be done in the short term about the second reason, especially in the context of working with developers outside your own company.

Upvotes: 2

Related Questions