Reputation: 2678
I'm developing a .NET 3.5 webservice using .asmx pages, but the fact that i cant use optional parameters in the GET and POST requests is making me think in switch my application to WCF. But I didnt understand clearly how it works.
Can you show me how the below code would be if converted to WCF?
[WebService]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[ScriptService]
public class ws :WebService
{
#region WebMethods
//Parameters shoud be optional but it isnt possible in .asmx .NET 3.5
[WebMethod]
public XmlNode GetResult(string param1(=null), string param2(= null))
{
MyClass myClass = new MyClass();
//Get a xml string
string output = myClass.GetXmlString(param1, param2);
//Load this xml
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(output);
//Return this xml
return xmlDocument.DocumentElement;
}
#endregion
}
Upvotes: 0
Views: 472
Reputation: 61589
WSDL cannot describe optional parameters, so it wouldn't matter if you are using ASMX or WCF contracts, the actual semantics of using optional parameters is redundant (they are still classed as required parameters - i.e. like all parameters).
Upvotes: 2