0

.asmxページを使用して.NET3.5Webサービスを開発していますが、GETおよびPOST要求でオプションのパラメーターを使用できないという事実から、アプリケーションをWCFに切り替えることを考えています。しかし、私はそれがどのように機能するかを明確に理解していませんでした。

以下のコードを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
}
4

1 に答える 1

2

WSDLはオプションのパラメーターを記述できないため、ASMXまたはWCFコントラクトを使用しているかどうかは関係ありません。オプションのパラメーターを使用する実際のセマンティクスは冗長です(つまり、すべてのパラメーターと同様に、必須パラメーターとして分類されます)。

于 2012-06-21T16:13:50.410 に答える