0

Web サービスに次のクラスがあります。

[Serializable]
public class WebServiceParam
{
    public string[] param;
}

クライアント アプリケーションで:

string[] reportFields = new string[] { "invoiceNo", "sale", "item", "size", "missingQty", "Country", "auto" };
param.ReportFields = reportFields;
serviceInstance.CreateReport(param);

ただし、文字列配列メンバーは「null」です

ここに私のWebサービスクラスがあります:

[WebService(Description = "Service related to producing various report formats", Namespace = "http://www.apacsale.com/ReportingService")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 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 ReportingService : System.Web.Services.WebService
{
    ReportingServiceImpl m_reporting;
    [WebMethod]
    public string CreateReport(ReportingParameters param)
    {
        if (param != null)
        {
            m_reporting = new ReportingServiceImpl(param);
            m_reporting.Create();
            return m_reporting.ReturnReport();
        }
        return null;
    }
}
4

2 に答える 2

0

param変数に関連する混乱があるように感じます。

WebServiceParam temp = new WebServiceParam();
string[] reportFields = new string[] { "invoiceNo", "sale", "item", "size", "missingQty", "Country", "auto" };
temp.param = reportFields;
serviceInstance.CreateReport(temp);
于 2013-02-08T10:07:52.787 に答える
0

クラスを [DataContract] 属性でマークする必要があり、配列はフィールドではなくプロパティにする必要があります。WebServiceParam は次のようになります。

[DataContract]
public class WebServiceParam
{
    [DataMember]
    public string[] Param {get; set;}
}

サービスインターフェイスは次のようになります。

[ServiceContract]
public interface IService
{
    [OperationContract]
    void CreateReport(WebServiceParam parameters);
}

今、あなたは使用することができます:

WebServiceParam wsParam = new WebServiceParam();
wsParam.Param = new string[] { "invoiceNo", "sale", "item", "size", "missingQty", "Country", "auto" };
serviceInstance.CreateReport(wsParam);
于 2013-02-08T10:16:15.703 に答える