Web Services SOAP网络服务C#

wvyml7n5  于 2022-12-13  发布在  C#
关注(0)|答案(1)|浏览(131)

我尝试呼叫SOAP Web服务,但回应部分发生错误。以下是服务档案:

public partial class ACCOUNT_REVIEW : System.Web.Services.Protocols.SOAPHttpClientProtocol {
    public ACCOUNT_REVIEW() {
       this.Url = "http://example.abs.cbn.com";
    }
    public AccountResultResponse AccountReviewResults (AccountReviewResults AccountReviewResults1) {
       object[] results = this.Invoke("AccountReviewResults", new object[] {AccountReviewResults1});
       return ((AccountResultResponse)(results[0]));
    }
    public System.IAsyncResult BeginAccountReviewResults(AccountReviewResults AccountReviewResults1, System.AsyncCallBack callback, object asyncState) {
       return this.BeginInvoke("AccountReviewResults", new object[] {AccountReviewResults1}, callback, asyncState);
    }
public AccountResultResponse EndAccountReviewResults(System.IAsyncResult asyncResult) {
    object[] results = this.EndInvoke(asyncResult);
       return ((AccountResultResponse)(results[0]));
    }
}

public partial class AccountReviewResults {
    private ReviewPeriodStructure[] tInAccReviewPeriodField;
    private ReviewResultsStructure[] tOutAccReviewResultsField;
    private ReviewApiReturn[] tOutApiReturnField;
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=False)]
    public ReviewPeriodStructure[] tInAccReviewPeriod {
        get {
           return this.tInAccReviewPeriodField;
        }
        set {
           this.tInAccReviewPeriodField = value;
        }
    }
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=False)]
    public ReviewResultsStructure[] tOutAccReviewResults {
        get {
           return this.tOutAccReviewResultsField;
        }
        set {
           this.tOutAccReviewResultsField = value;
        }
    }
}

public partial class ReviewPeriodStructure {
    private string accReviewPeriodField;
    public string AccReviewPeriod {
        get {
           return this.accReviewPeriodField;
        }
        set {
           this.accReviewPeriodField = value;
        }
    }
}

public partial class ReviewResultsStructure {
    private string moduleField;
    private string typeField;
    private string statusField;

    public string Module {
        get {
           return this.moduleField;
        }
        set {
           this.moduleField = value;
        }
    }
    public string Type {
        get {
           return this.typeField;
        }
        set {
           this.typeField = value;
        }
    }
    public string Status {
        get {
           return this.statusField;
        }
        set {
           this.statusField = value;
        }
    }   
}

这是我检索数据的代码。

ACCOUNT_REVIEW account_review = new ACCOUNT_REVIEW();
account_review.Credentials = new NetworkCredential("admin", "admin");
var accountReviewResults = new AccountReviewResults();
var accountReviewPeriod = new ReviewPeriodStructure();
accountReviewPeriod.AccReviewPeriod = "MAY-2022";
ReviewPeriodStructure[] reviewPeriod = {accountReviewPeriod};
accountReviewResults.tInAccReviewPeriod = reviewPeriod;

// I am getting an error here when passing the value of accountReviewResults into the response.
AccountResultResponse res = account_review.AccountReviewResults(accountReviewResults);

是有一个丢失的代码或我做错了吗?我只是按照结构的基础上从服务文件。我需要你的专业知识的家伙:(。我仍然是noob当谈到网络服务。
提前感谢你的大力帮助。

2vuwiymt

2vuwiymt1#

由于您没有粘贴出您的错误信息,我认为这可能是由以下原因造成的。
1.我在你贴的代码中没有看到合约特性。通常WCF中有几个合约特性:1.服务协定2.数据协定3.消息协定,.
2.您的服务器段是否与客户端终结点匹配。如果您发布错误消息,我将更好地帮助您解决问题。
此致
齐佑

相关问题