Avatar billede chakazulu Nybegynder
07. december 2015 - 16:00 Der er 1 løsning

C# write to class - API klare resten

Hej Herinde.
Jeg sidder lidt fast i at sende nogle data via API.
Kan fint trække data ud via API C#, men når jeg prøver at sende data til en Class sker der intet.

Jeg har prøvet en masse forskellige calls, men har nu simplificeret koden så den er mere overskuelig.

Jeg vil indsætte data(ordre) på et website via API.
Har lagt code behind og Classen jeg henviser til.*

Håber der er nogle der kan pege mig i den rigtige retning.
Der er noget dokumentation her.: https://api.smart-web.dk/doc/

Code behind call 
WebServiceService objWebService = new WebServiceService();

  protected void btnordercreate_Click(object sender, EventArgs e)
    {
     
 

        objWebService.CookieContainer = new System.Net.CookieContainer();
        objWebService.Solution_Connect("USER", "PASSWORD");
        objWebService.Solution_SetLanguage("DK");

        OrderCreate OrderNew = new OrderCreate();
     
        OrderNew.CurrencyId = 57;

        OrderNew.CustomerComment = "test";
        OrderNew.DeliveryId = 58;
        OrderNew.DeliveryPrice = 1000;

      OrderNew.Origin = "Test";
        OrderNew.PaymentId = 58;

        OrderNew.ReferenceNumber = "29374";

        OrderNew.UserId = 18;
}

The Class

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="https://api.smart-web.dk/service.php")]
public partial class OrderCreate {
   
    private int currencyIdField;
   
    private int userIdField;
   
    private bool userIdFieldSpecified;
   
    private int paymentIdField;
   
    private int paymentOnlineIdField;
   
    private bool paymentOnlineIdFieldSpecified;
   
    private string customerCommentField;
   
    private int deliveryIdField;
   
    private double deliveryPriceField;
   
    private bool deliveryPriceFieldSpecified;
   
    private string referenceNumberField;
   
    private OrderLineCreate[] orderLinesField;
   
    private OrderCustomerCreate orderCustomerField;
   
    private OrderTransactionCreate orderTransactionField;
   
    private string originField;
   
    private OrderDelivery deliveryField;
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public int CurrencyId {
        get {
            return this.currencyIdField;
        }
        set {
            this.currencyIdField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public int UserId {
        get {
            return this.userIdField;
        }
        set {
            this.userIdField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool UserIdSpecified {
        get {
            return this.userIdFieldSpecified;
        }
        set {
            this.userIdFieldSpecified = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public int PaymentId {
        get {
            return this.paymentIdField;
        }
        set {
            this.paymentIdField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public int PaymentOnlineId {
        get {
            return this.paymentOnlineIdField;
        }
        set {
            this.paymentOnlineIdField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool PaymentOnlineIdSpecified {
        get {
            return this.paymentOnlineIdFieldSpecified;
        }
        set {
            this.paymentOnlineIdFieldSpecified = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string CustomerComment {
        get {
            return this.customerCommentField;
        }
        set {
            this.customerCommentField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public int DeliveryId {
        get {
            return this.deliveryIdField;
        }
        set {
            this.deliveryIdField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public double DeliveryPrice {
        get {
            return this.deliveryPriceField;
        }
        set {
            this.deliveryPriceField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool DeliveryPriceSpecified {
        get {
            return this.deliveryPriceFieldSpecified;
        }
        set {
            this.deliveryPriceFieldSpecified = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string ReferenceNumber {
        get {
            return this.referenceNumberField;
        }
        set {
            this.referenceNumberField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public OrderLineCreate[] OrderLines {
        get {
            return this.orderLinesField;
        }
        set {
            this.orderLinesField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public OrderCustomerCreate OrderCustomer {
        get {
            return this.orderCustomerField;
        }
        set {
            this.orderCustomerField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public OrderTransactionCreate OrderTransaction {
        get {
            return this.orderTransactionField;
        }
        set {
            this.orderTransactionField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public string Origin {
        get {
            return this.originField;
        }
        set {
            this.originField = value;
        }
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public OrderDelivery Delivery {
        get {
            return this.deliveryField;
        }
        set {
            this.deliveryField = value;
        }
    }
}
Avatar billede chakazulu Nybegynder
09. december 2015 - 13:12 #1
Nå, det var ikke så svært.
Den drillede mig bare lidt.

Solution hvis andre skulle bruge det.

Code behind call 
WebServiceService objWebService = new WebServiceService();

  protected void btnordercreate_Click(object sender, EventArgs e)
    {
     
 

        objWebService.CookieContainer = new System.Net.CookieContainer();
        objWebService.Solution_Connect("USER", "PASSWORD");
        objWebService.Solution_SetLanguage("DK");

        OrderCreate OrderNew = new OrderCreate();
     
        OrderNew.CurrencyId = 1;

        OrderNew.CustomerComment = "test";
        OrderNew.DeliveryId = 1;
        OrderNew.DeliveryPrice = 1000;

      OrderNew.Origin = "Test";
        OrderNew.PaymentId = 1;

        OrderNew.ReferenceNumber = "123456789";

        OrderNew.UserId = 1;

        objWebService.Order_Create(OrderNew);
}
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester