Jump to content

Community durchsuchen

Zeige Ergebnisse für die Stichwörter "'csharp'".

  • Suche mithilfe von Stichwörtern

    Trenne mehrere Stichwörter mit Kommata voneinander
  • Suche Inhalte eines Autors

Inhaltstyp


Forum

  • Forum
  • Ausbildung/Job
    • Ausbildung im IT-Bereich
    • IT-Arbeitswelt
    • IT-Weiterbildung
    • Stellenangebote für Fachinformatiker
    • Jobsuche, Bewerbung und Zeugnisse
  • Prüfungsforen
    • IHK-Prüfung allgemein
    • Prüfungsaufgaben und -lösungen
    • Abschlussprojekte
  • NEU: Frage / Antwort: 1. Frage stellen - 2. Antworten bekommen - 3. Die beste Antwort auswählen
    • Für Systemadministratoren und Netzwerktechniker
    • Für Anwendungsentwickler und Programmierer
  • Fachliche Foren
    • Administration
    • Programmierung
  • Sonstiges
    • News und Feedback zu Fachinformatiker.de
    • Small Talk
  • Fachinformatiker.de Treffen's regionale Treffen
  • Coffeehouse's Themen
  • Gaming Club's Allgemeine Themen
  • Gaming Club's Games
  • Coffeehouse's Soap

Kalender

  • Fachinformatiker.de Treffen's Kalender
  • Gaming Club's Verabreden zum Zocken

Blogs

Keine Suchergebnisse

Keine Suchergebnisse


3 Ergebnisse gefunden

  1. Hallo liebe Entwicklerfreunde. Ich beschäftige mich momentan ein bisschen mit REST WebAPI sowie der Anbindung mittels UnitOfWork / Repository pattern. Dazu habe ich mir einen Selfhosted Server basierend auf den von Microsoft verfügbaren Selfthosted WebAPI Bibliotheken gebaut sowie eine Client Applikation die mittels restsharp Bibliothek an jenen Server Daten senden soll. Folgendes Problem tut sich auf: Beim POST landet der request vom Client zwar beim richtigen Controller, das übergebene Objekt habt aber immer leere Werte. Führe ich den POST beim Server mit der Chrome Erweiterung "ARC(Advanced REST Client)" aus klappt das einwandfrei. Beim client debuggen habe ich mir den serialiserten JSON String aus dem request gezogen und in die Chrome Erweiterung kopiert. Der JSON String ist gültig und wird von dort aus auch beim Server akzeptiert. Sämtliche CRUD Methoden funktionieren mit dem Advanced REST Client, daher denke ich ist hier die Server Seite auszuschließen. Hier der entsprechende Code aus der ApiController Klasse: [HttpPost] public HttpResponseMessage Post([FromBody]LiquidBase _liquidBase) { repo.InsertOrUpdate(_liquidBase); repo.Save(); return new HttpResponseMessage(HttpStatusCode.OK); } _liquidBase hat hier in dem Fall immer Nullwerte sobald ich etwas vom Client aus POST(e). Hier die Funktion welche beim Client den POST übernimmt. internal ResponseMessage PostLiquidBase(LiquidBase _liquidBase) { RestClient client = getAuthenticatedClient(config); RestRequest request = new RestRequest("api/LiquidBase", Method.POST); string data = JsonConvert.SerializeObject(_liquidBase); data = data.Replace("\"Id\":0,", string.Empty); request.AddParameter("application/json", data, ParameterType.RequestBody); request.RequestFormat = DataFormat.Json; return GetWebResponse(client, request); } GetWebResponse(client, request) executed das ganze dann nur noch IRestResponse response = client.Execute(request); und wertet die response dann weiter aus. Ist hier aber nicht weiter wichtig da es ja ab dem execute, bzw dem Empfang beim Server irgendwo schief läuft. Ich hoffe jemand weiß weiter. Euer Tehrob
  2. C# Code

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UPSShipWS; namespace Paket { class Class1 { public static void Main(string[] args) { Adresse versender = new Adresse(); versender.Anrede = "Herr"; versender.Name = "Blondie"; versender.Nachname = "Müller"; versender.Anschrift = "Musterstraße 8"; versender.Ort = "Bielefeld"; versender.Postleitzahl = "33607"; versender.Bundesland = "DE"; versender.Telefonnummer = "05211234"; Adresse empfänger = new Adresse(); empfänger.Anrede = "Frau"; empfänger.Name = "Anna"; empfänger.Nachname = "Mustermann"; empfänger.Anschrift = "Kirchstraße 7"; empfänger.Ort = "Köln"; empfänger.Postleitzahl = "12345"; empfänger.Bundesland = "DE"; empfänger.Telefonnummer = "052145678"; Pakettyp paket = new Pakettyp(); paket.Breite = "10"; paket.Höhe = "5"; paket.Tiefe = "6"; paket.Gewicht = "4"; paket.Unit = "kg"; Label ausdruck = new Label(); ausdruck.Höhe = "5"; ausdruck.Breite = "8"; ausdruck.Format = "Gif"; ausdruck.DistanceUnit = "cm"; string shipperNumber = "A32E55"; Package package = new Package ("6CCE28CFBB6BB67B", "intecadmin", "37170Uslar","Mein Paket", shipperNumber, shipperNumber, versender.AnschriftToArray(), versender.Ort, versender.Postleitzahl, versender.Name, versender.Nachname, versender.Telefonnummer, "DE" , "NRW", versender.AnschriftToArray()); package.setTestMode(); package.addPackage("BX", "CP", "8"); UPSShipWS.ShipWeb.ShipmentResultsType test = package.sendPackage(versender.AnschriftToArray(), versender.Ort, versender.Postleitzahl, versender.Bundesland, versender.Name, versender.Nachname, "NRW", empfänger.AnschriftToArray(), empfänger.Ort, empfänger.Postleitzahl, empfänger.Bundesland, empfänger.Name, empfänger.Nachname, empfänger.Telefonnummer, "NRW", "Standard", "ST", ausdruck.Höhe, ausdruck.Breite, ausdruck.Format); if(test == null) { Console.WriteLine(package.errorstring); } Console.WriteLine("Test Paket: " + test); Console.ReadKey(); } } } Als Fehlermeldung bekomme ich : ...an exeption has been raised as a rsult of client data...shipment can have only one type of unit of measurement for a weight... Weiss jemand wo der Fehler ist ? In der API steht: using System; using System.Collections.Generic; using System.Text; using UPSShipWS.ShipWeb; using UPSShipWS.VoidWeb; using UPSShipWS.TrackWeb; using System.ServiceModel; using System.Configuration; using System.Collections; namespace UPSShipWS { public class Package { private String AccessLicenseNumber; private String Username; private String Password; private String Description; private String ShipperNumber; private String AccountNumber; private String[] AddressLine; private String ShipperCity; private String ShipperPostalCode; private String ShipperName; private String ShipperAttentionName; private String ShipperPhone; private String ShipperCountryCode; private String ShipperStateProvinceCode; private String[] RequestOption; private ShipService shpSvc; private VoidService voidService; private TrackService track; public String errorstring; ArrayList packages = new ArrayList(); public Package( String AccessLicenseNumber, String Username, String Password, String Description, String ShipperNumber, String AccountNumber, String[] addressLine, String ShipperCity, String ShipperPostalCode, String ShipperName, String ShipperAttentionName, String ShipperPhone, String ShipperCountryCode, String ShipperStateProvinceCode, String[] RequestOption) { shpSvc = new ShipService(); voidService = new VoidService(); track = new TrackService(); setTestMode(); this.AccessLicenseNumber = AccessLicenseNumber; this.Username = Username; this.Password = Password; this.Description = Description; this.ShipperNumber = ShipperNumber; this.AccountNumber = AccountNumber; this.AddressLine = addressLine; this.ShipperCity = ShipperCity; this.ShipperPostalCode = ShipperPostalCode; this.ShipperName = ShipperName; this.ShipperAttentionName = ShipperAttentionName; this.ShipperPhone = ShipperPhone; this.ShipperCountryCode = ShipperCountryCode; this.RequestOption = RequestOption; this.ShipperStateProvinceCode = ShipperStateProvinceCode; } public void addPackage( String UomCode, String PackTypeCode, String PackageWeight ) { ShipWeb.PackageType package = new ShipWeb.PackageType(); PackageWeightType packageWeight = new PackageWeightType(); ShipUnitOfMeasurementType uom = new ShipUnitOfMeasurementType(); PackagingType packType = new PackagingType(); packageWeight.Weight = PackageWeight; uom.Code = UomCode; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; packType.Code = PackTypeCode; package.Packaging = packType; this.packages.Add(package); } public void setTestMode() { shpSvc.Url = "https://wwwcie.ups.com/webservices/Ship"; voidService.Url = "https://wwwcie.ups.com/webservices/Track"; track.Url = "https://wwwcie.ups.com/webservices/Void"; } public void setProductionMode() { shpSvc.Url = "https://onlinetools.ups.com/webservices/Ship"; voidService.Url = "https://onlinetools.ups.com/webservices/Track"; track.Url = "https://onlinetools.ups.com/webservices/Void"; } public ShipmentResultsType sendPackage( String[] ShipFromAddressLine, String ShipFromCity, String ShipFromPostalCode, String ShipFromCountryCode, String ShipFromAttentionName, String ShipFromName, String ShipFromStateProvinceCode, String[] ShipToAddressLine, String ShipToCity, String ShipToPostalCode, String ShipToCountryCode, String ShipToAttentionName, String ShipToName, String ShipToPhone, String ShipToStateProvinceCode, String ShpmentChargeType, String ServiceCode, String LbelStockSizeHeight, String LabelStockSizeWidth, String LabelImageFormat ) { ShipmentResultsType result = null; ShipWeb.UPSSecurity upss = new ShipWeb.UPSSecurity(); ShipWeb.UPSSecurityServiceAccessToken upssSvcAccessToken = new ShipWeb.UPSSecurityServiceAccessToken(); ShipWeb.UPSSecurityUsernameToken upssUsrNameToken = new ShipWeb.UPSSecurityUsernameToken(); ShipWeb.RequestType request = new ShipWeb.RequestType(); ShipWeb.ShipmentType shipment = new ShipWeb.ShipmentType(); ShipperType ShipperTypeshipper = new ShipperType(); PaymentInfoType paymentInfo = new PaymentInfoType(); ShipmentChargeType shpmentCharge = new ShipmentChargeType(); BillShipperType billShipper = new BillShipperType(); ShipmentChargeType[] shpmentChargeArray = { shpmentCharge }; ShipFromType shipFrom = new ShipFromType(); ShipToType shipTo = new ShipToType(); ShipToAddressType shipToAddress = new ShipToAddressType(); ShipPhoneType shipToPhone = new ShipPhoneType(); ShipWeb.ServiceType service = new ShipWeb.ServiceType(); LabelSpecificationType labelSpec = new LabelSpecificationType(); LabelStockSizeType labelStockSize = new LabelStockSizeType(); LabelImageFormatType labelImageFormat = new LabelImageFormatType(); ShipAcceptRequest shipAcceptRequest = new ShipAcceptRequest(); ShipConfirmRequest shipmentRequest = new ShipConfirmRequest(); ShipperType shipper = new ShipperType(); upssSvcAccessToken.AccessLicenseNumber = AccessLicenseNumber; upss.ServiceAccessToken = upssSvcAccessToken; upssUsrNameToken.Username = Username; upssUsrNameToken.Password = Password; upss.UsernameToken = upssUsrNameToken; shpSvc.UPSSecurityValue = upss; request.RequestOption = RequestOption; shipmentRequest.Request = request; shipment.Description = Description; shipper.ShipperNumber = ShipperNumber; billShipper.AccountNumber = AccountNumber; shpmentCharge.BillShipper = billShipper; shpmentCharge.Type = ShpmentChargeType; paymentInfo.ShipmentCharge = shpmentChargeArray; shipment.PaymentInformation = paymentInfo; UPSShipWS.ShipWeb.ShipAddressType shipperAddress = new UPSShipWS.ShipWeb.ShipAddressType(); shipperAddress.AddressLine = AddressLine; shipperAddress.City = ShipperCity; shipperAddress.PostalCode = ShipperPostalCode; shipperAddress.StateProvinceCode = ShipperStateProvinceCode; shipperAddress.CountryCode = ShipperCountryCode; shipper.Address = shipperAddress; shipper.Name = ShipperName; shipper.AttentionName = ShipperAttentionName; ShipPhoneType shipperPhone = new ShipPhoneType(); shipperPhone.Number = ShipperPhone; shipper.Phone = shipperPhone; shipment.Shipper = shipper; try { UPSShipWS.ShipWeb.ShipAddressType shipFromAddress = new UPSShipWS.ShipWeb.ShipAddressType(); shipFromAddress.AddressLine = ShipFromAddressLine; shipFromAddress.City = ShipFromCity; shipFromAddress.PostalCode = ShipFromPostalCode; shipFromAddress.StateProvinceCode = ShipFromStateProvinceCode; shipFromAddress.CountryCode = ShipFromCountryCode; shipFrom.Address = shipFromAddress; shipFrom.AttentionName = ShipFromAttentionName; shipFrom.Name = ShipFromName; shipment.ShipFrom = shipFrom; shipToAddress.AddressLine = ShipToAddressLine; shipToAddress.City = ShipToCity; shipToAddress.PostalCode = ShipToPostalCode; shipToAddress.StateProvinceCode = ShipToStateProvinceCode; shipToAddress.CountryCode = ShipToCountryCode; shipTo.Address = shipToAddress; shipTo.AttentionName = ShipToAttentionName; shipTo.Name = ShipToName; shipToPhone.Number = ShipToPhone; shipTo.Phone = shipToPhone; shipment.ShipTo = shipTo; service.Code = ServiceCode; shipment.Service = service; shipment.Package = (ShipWeb.PackageType[])packages.ToArray(typeof(ShipWeb.PackageType)); labelStockSize.Height = LbelStockSizeHeight; labelStockSize.Width = LabelStockSizeWidth; labelSpec.LabelStockSize = labelStockSize; labelImageFormat.Code = LabelImageFormat; labelSpec.LabelImageFormat = labelImageFormat; shipmentRequest.LabelSpecification = labelSpec; shipmentRequest.Shipment = shipment; ShipConfirmResponse shipmentResponse = shpSvc.ProcessShipConfirm(shipmentRequest); shipAcceptRequest.Request = request; shipAcceptRequest.ShipmentDigest = shipmentResponse.ShipmentResults.ShipmentDigest; ShipAcceptResponse shipAccept = shpSvc.ProcessShipAccept(shipAcceptRequest); result = shipAccept.ShipmentResults; } catch (System.Web.Services.Protocols.SoapException ex) { errorstring = "<ERR>" + "<TYPE>SoapException</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<CCMSG>" + ex.Detail.LastChild.InnerText + "</CCMSG>" + "<VALUE>" + ex.Detail.Value + "</VALUE>" + "<SCHEMA>" + ex.Detail.SchemaInfo + "</SCHEMA>" + "<SHIPURL>" + shpSvc.Url + "<SHIPURL>" +"</ERR>" ; } catch (System.ServiceModel.CommunicationException ex) { errorstring = "<ERR>" + "<TYPE>CommunicationException</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<TRACE>" + ex.StackTrace + "</TRACE>" + "<SHIPURL>" + shpSvc.Url + "<SHIPURL>" + "</ERR>" ; } catch (Exception ex) { errorstring = "<ERR>" + "<TYPE>Exception</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<TRACE>" + ex.StackTrace + "</TRACE>" + "<SHIPURL>" + shpSvc.Url + "<SHIPURL>" + "</ERR>" ; } return result; } public UPSShipWS.VoidWeb.VoidShipmentResponse VoidPackage(String ShipmentIdentificationNumber) { UPSShipWS.VoidWeb.VoidShipmentResponse voidResponse = null; try { UPSShipWS.VoidWeb.VoidShipmentRequest voidRequest = new UPSShipWS.VoidWeb.VoidShipmentRequest(); VoidWeb.RequestType request = new VoidWeb.RequestType(); //String[] requestOption = { "1" }; //request.RequestOption = requestOption; voidRequest.Request = request; UPSShipWS.VoidWeb.VoidShipmentRequestVoidShipment voidShipment = new UPSShipWS.VoidWeb.VoidShipmentRequestVoidShipment(); voidShipment.ShipmentIdentificationNumber = ShipmentIdentificationNumber; voidRequest.VoidShipment = voidShipment; UPSShipWS.VoidWeb.UPSSecurity upss = new UPSShipWS.VoidWeb.UPSSecurity(); UPSShipWS.VoidWeb.UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSShipWS.VoidWeb.UPSSecurityServiceAccessToken(); upssSvcAccessToken.AccessLicenseNumber = this.AccessLicenseNumber; upss.ServiceAccessToken = upssSvcAccessToken; UPSShipWS.VoidWeb.UPSSecurityUsernameToken upssUsrNameToken = new UPSShipWS.VoidWeb.UPSSecurityUsernameToken(); upssUsrNameToken.Username = this.Username; upssUsrNameToken.Password = this.Password; upss.UsernameToken = upssUsrNameToken; voidService.UPSSecurityValue = upss; voidResponse = voidService.ProcessVoid(voidRequest); } catch (System.Web.Services.Protocols.SoapException ex) { errorstring = "<ERR>" + "<TYPE>SoapException</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<CCMSG>" + ex.Detail.LastChild.InnerText + "</CCMSG>" + "<VALUE>" + ex.Detail.Value + "</VALUE>" + "<SCHEMA>" + ex.Detail.SchemaInfo + "</SCHEMA>" + "</ERR>" ; } catch (System.ServiceModel.CommunicationException ex) { errorstring = "<ERR>" + "<TYPE>CommunicationException</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<TRACE>" + ex.StackTrace + "</TRACE>" + "</ERR>" ; } catch (Exception ex) { errorstring = "<ERR>" + "<TYPE>Exception</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<TRACE>" + ex.StackTrace + "</TRACE>" + "</ERR>" ; } return voidResponse; } public UPSShipWS.TrackWeb.TrackResponse TrackPackage(String ShipmentIdentificationNumber) { UPSShipWS.TrackWeb.TrackResponse trackResponse = null; try { UPSShipWS.TrackWeb.TrackRequest tr = new UPSShipWS.TrackWeb.TrackRequest(); UPSShipWS.TrackWeb.UPSSecurity upss = new UPSShipWS.TrackWeb.UPSSecurity(); UPSShipWS.TrackWeb.UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSShipWS.TrackWeb.UPSSecurityServiceAccessToken(); upssSvcAccessToken.AccessLicenseNumber = this.AccessLicenseNumber; upss.ServiceAccessToken = upssSvcAccessToken; UPSShipWS.TrackWeb.UPSSecurityUsernameToken upssUsrNameToken = new UPSShipWS.TrackWeb.UPSSecurityUsernameToken(); upssUsrNameToken.Username = this.Username; upssUsrNameToken.Password = this.Password; upss.UsernameToken = upssUsrNameToken; track.UPSSecurityValue = upss; UPSShipWS.TrackWeb.RequestType request = new UPSShipWS.TrackWeb.RequestType(); String[] requestOption = { "1" }; request.RequestOption = requestOption; tr.Request = request; tr.InquiryNumber = ShipmentIdentificationNumber; trackResponse = track.ProcessTrack(tr); } catch (System.Web.Services.Protocols.SoapException ex) { errorstring = "<ERR>" + "<TYPE>SoapException</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<CCMSG>" + ex.Detail.LastChild.InnerText + "</CCMSG>" + "<VALUE>" + ex.Detail.Value + "</VALUE>" + "<SCHEMA>" + ex.Detail.SchemaInfo + "</SCHEMA>" + "</ERR>" ; } catch (System.ServiceModel.CommunicationException ex) { errorstring = "<ERR>" + "<TYPE>CommunicationException</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<TRACE>" + ex.StackTrace + "</TRACE>" + "</ERR>" ; } catch (Exception ex) { errorstring = "<ERR>" + "<TYPE>Exception</TYPE>" + "<MSG>" + ex.Message + "</MSG>" + "<TRACE>" + ex.StackTrace + "</TRACE>" + "</ERR>" ; } return trackResponse; } } }
  3. Guten Morgen kennt sich einer aus mit den Api's von UPS?
×