关于C#代码中的XMLResponse gettiing错误

时间:2017-07-17 06:16:26

标签: c# web-services soap windows-applications

这是Windows应用程序,它只使用一个按钮来调用SOAP Web服务调用。 此错误是我的产品SOAP WebServices之一,其名称为SwiftKanban。 我尝试从WSDL中使用AddCard WebServices,我看到SwiftKanban在给定的项目ID中添加了该卡,但在返回时响应显示错误。

private void syncBoard_Click(object sender, EventArgs e)
{

    kanbanCardPortTypeClient serviceClient = new kanbanCardPortTypeClient("KanbancardServiceSOAP12port");
    var cardFieldName1 = new swKanbanCardService.fieldType();
    cardFieldName1.name = "name";
    cardFieldName1.Value = "UserStory test Code C# date 14th July 2017";

    var cardFieldName2 = new swKanbanCardService.fieldType();
    cardFieldName2.name = "priority";
    cardFieldName2.Value = "High";

    var cardFieldName3 = new swKanbanCardService.fieldType();
    cardFieldName3.name = "currentOwner";
    cardFieldName3.Value = "MyUserName";

    var cardFieldName4 = new swKanbanCardService.fieldType();
    cardFieldName4.name = "description";
    cardFieldName4.Value = "description: UserStory test Code C# date 14th July 2017";

    swKanbanCardService.fieldType[] cardFields = { cardFieldName1, cardFieldName2 , cardFieldName3, cardFieldName4 };

    var cardDetails = new swKanbanCardService.addCardDetails();
    cardDetails.cardType = "UserStory";
    cardDetails.projectId = "Number_PRJ_ID";
    cardDetails.userLoginId = "MyUserName";
    cardDetails.fields = cardFields;

    swKanbanCardService.kanbanCardPortTypeClient swKanbanClient = new swKanbanCardService.kanbanCardPortTypeClient("KanbancardServiceSOAP12port");
    swKanbanClient.ClientCredentials.UserName.UserName = "MyUserName";
    swKanbanClient.ClientCredentials.UserName.Password = "########";


    swKanbanCardService.addCardResponse response = swKanbanClient.addCard(cardDetails);

    System.Xml.XmlElement[] xmlResponse = response.Any;
    Console.WriteLine(xmlResponse[0].InnerXml.ToString());
    Console.Read();        
}

Error Img for Ref

如果需要更多信息,请告诉我。

addCardDetails方法代码:

public partial class addCardDetails : object, System.ComponentModel.INotifyPropertyChanged 
{
    private string projectIdField;
    private string cardTypeField;
    private string userLoginIdField;
    private fieldType[] fieldsField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order=0)]
    public string projectId {
        get {
            return this.projectIdField;
        }
        set {
            this.projectIdField = value;
            this.RaisePropertyChanged("projectId");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Order=1)]
    public string cardType {
        get {
            return this.cardTypeField;
        }
        set {
            this.cardTypeField = value;
            this.RaisePropertyChanged("cardType");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Order=2)]
    public string userLoginId {
        get {
            return this.userLoginIdField;
        }
        set {
            this.userLoginIdField = value;
            this.RaisePropertyChanged("userLoginId");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Order=4)]
    [System.Xml.Serialization.XmlArrayItemAttribute("field", IsNullable=false)]
    public fieldType[] fields {
        get {
            return this.fieldsField;
        }
        set {
            this.fieldsField = value;
            this.RaisePropertyChanged("fields");
        }
    }

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName) {
        System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
        if ((propertyChanged != null)) {
            propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }
}

addCardResponse方法代码:

public partial class addCardResponse : object, System.ComponentModel.INotifyPropertyChanged 
{
    private System.Xml.XmlElement[] anyField;

    /// <remarks/>
    [System.Xml.Serialization.XmlAnyElementAttribute(Order=0)]
    public System.Xml.XmlElement[] Any {
        get {
            return this.anyField;
        }
        set {
            this.anyField = value;
            this.RaisePropertyChanged("Any");
        }
    }

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName) {
        System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
        if ((propertyChanged != null)) {
            propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }
}

0 个答案:

没有答案