0

This is Windows Application used only one button on this for calling SOAP Web-Services calling. This Error is one of my product SOAP WebServices, which is name as SwiftKanban. I tried for AddCard WebServices from WSDL, I saw that card is Added on SwiftKanban in given Project ID but on return the response show Error.

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

Let Me know in case need more information.

addCardDetails method code:

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 method code:

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));
        }
    }
}
Dovydas Šopa
  • 2,282
  • 8
  • 26
  • 34
  • Your response is `null`. Check your `swKanbanClient.addCard(cardDetails)` method – Samvel Petrosov Jul 17 '17 at 06:18
  • As @SamvelPetrosov suggests, the problem is with your `swKanbanClient.addCard(cardDetails)` method, since you mention it adds the card successfully, perhaps you add it without returning a corresponding addCardResponse value? – Keyur PATEL Jul 17 '17 at 06:21
  • for addCard Correct – Niket Patil Jul 17 '17 at 06:21
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Samvel Petrosov Jul 17 '17 at 06:22
  • @KeyurPATEL Yes Correct, facing issue on addCardResponse but in java code when we execute same AddCard WebService, it has work return addcard unique ID, but in C# code getting response as NULL. Let me know if any solution. – Niket Patil Jul 17 '17 at 06:24
  • It would be impossible to solve without taking a look at the function, could you post relevant parts / all of the code of your `addCard()` method? – Keyur PATEL Jul 17 '17 at 06:25
  • @KeyurPATEL: Yes Sure Let check once again the Code. – Niket Patil Jul 17 '17 at 06:36
  • @SamvelPetrosov: This is not duplicate, why You claim as duplicate this is issue has different... card has added on that Kanban Board but in response get null...? don't know why you point out it's duplication and if you not passing any value it's should be NullReferenceException. So not only that steps are used for resolved which your posted link. – Niket Patil Jul 17 '17 at 06:43
  • Thank you for the extra code, but that is just your class, we would need code for the exact method `swKanbanClient.addCard()` to help. – Keyur PATEL Jul 17 '17 at 06:45
  • @NiketPatil you are getting `NullReferenceException` because of calling `response.Any` LINQ's method which is throwing `NullReferenceException` exception in case if called on `object` which is `null`. – Samvel Petrosov Jul 17 '17 at 06:46
  • @KeyurPATEL: swKanbanClient is a object of swKanbanCardService.kanbanCardPortTypeClient.... let check code once – Niket Patil Jul 17 '17 at 06:51
  • @SamvelPetrosov Actually he has a public variable called `Any` which he handles the getter and setter for. The choice of naming is less than ideal. – Keyur PATEL Jul 17 '17 at 06:51
  • 1
    @KeyurPATEL anyway his problem is that response is `null` and he calling something on `null`. This code should be debugged and of course we shouldn't do it instead of him – Samvel Petrosov Jul 17 '17 at 06:52
  • @SamvelPetrosov: What is Solution for this, how I getting response as that addcard unique ID. – Niket Patil Jul 17 '17 at 07:03
  • 1
    @NiketPatil debug your code and find out why the returned value is `null`. – Samvel Petrosov Jul 17 '17 at 07:07

0 Answers0