Need Raw XML For Request & Response In UPS API (.Net)

ScriptKing

New Member
The answer to this may be painfully obvious. But need some help...I'm currently using the UPS API/Service to generate test labels. Everything is working great. But to get it certified, I have to send UPS the raw XML from the requests & responses.I'm not sending raw xml, but rather using the service and its various properties. Is there a raw XML returned somewhere within the shipment result? Or do have to manually serialize the request & responses just to satisfy what UPS wants in their review?Here's my code (everything works, I'm able to generate a label. But how do I get request & response xml?)\[code\]try { ShipService shpSvc = new ShipService(); ShipmentRequest shipmentRequest = new ShipmentRequest(); UPSSecurity upss = new UPSSecurity(); UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken(); upssSvcAccessToken.AccessLicenseNumber = s.APIKey; upss.ServiceAccessToken = upssSvcAccessToken; UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken(); upssUsrNameToken.Username = s.Username; upssUsrNameToken.Password = s.Password; upss.UsernameToken = upssUsrNameToken; shpSvc.UPSSecurityValue = http://stackoverflow.com/questions/11365715/upss; RequestType request = new RequestType(); String[] requestOption = {"nonvalidate" }; request.RequestOption = requestOption; shipmentRequest.Request = request; ShipmentType shipment = new ShipmentType(); ShipperType shipper = new ShipperType(); shipper.ShipperNumber = s.ShipperAccountNumber; PaymentInfoType paymentInfo = new PaymentInfoType(); ShipmentChargeType shpmentCharge = new ShipmentChargeType(); BillShipperType billShipper = new BillShipperType(); billShipper.AccountNumber = s.ShipperAccountNumber; shpmentCharge.BillShipper = billShipper; shpmentCharge.Type = "01"; ShipmentChargeType[] shpmentChargeArray = { shpmentCharge }; paymentInfo.ShipmentCharge = shpmentChargeArray; shipment.PaymentInformation = paymentInfo; ShipWebReference.ShipAddressType shipperAddress = new ShipWebReference.ShipAddressType(); String[] addressLine = { s.ShipperAddressLine }; shipperAddress.AddressLine = addressLine; shipperAddress.City = s.ShipperCity; shipperAddress.PostalCode = s.ShipperZip; shipperAddress.StateProvinceCode = s.ShipperState; shipperAddress.CountryCode = "US"; shipperAddress.AddressLine = addressLine; shipper.Address = shipperAddress; shipper.Name = s.ShipperName; shipper.AttentionName = s.ShipperName; ShipPhoneType shipperPhone = new ShipPhoneType(); shipperPhone.Number = s.ShipperPhone; shipper.Phone = shipperPhone; shipment.Shipper = shipper; ShipFromType shipFrom = new ShipFromType(); ShipWebReference.ShipAddressType shipFromAddress = new ShipWebReference.ShipAddressType(); String[] shipFromAddressLine = { s.ShipperAddressLine }; shipFromAddress.AddressLine = addressLine; shipFromAddress.City = s.ShipperCity; shipFromAddress.PostalCode = s.ShipperZip; shipFromAddress.StateProvinceCode = s.ShipperState; shipFromAddress.CountryCode = "US"; shipFrom.Address = shipFromAddress; shipFrom.AttentionName = s.ShipperName; shipFrom.Name = s.ShipperName; shipment.ShipFrom = shipFrom; ShipToType shipTo = new ShipToType(); ShipToAddressType shipToAddress = new ShipToAddressType(); String[] addressLine1 = { s.ShipToAddressLine }; shipToAddress.AddressLine = addressLine1; shipToAddress.City = s.ShipToCity; shipToAddress.PostalCode = s.ShipToZip; shipToAddress.StateProvinceCode = s.ShipToState; shipToAddress.CountryCode = "US"; shipTo.Address = shipToAddress; shipTo.AttentionName = s.ShipToName; shipTo.Name = s.ShipToName; ShipPhoneType shipToPhone = new ShipPhoneType(); shipToPhone.Number = s.ShipToPhone; shipTo.Phone = shipToPhone; shipment.ShipTo = shipTo; ServiceType service = new ServiceType(); service.Code = "03"; shipment.Service = service; PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = s.PackageWeight; ShipUnitOfMeasurementType uom = new ShipUnitOfMeasurementType(); uom.Code = "LBS"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; PackagingType packType = new PackagingType(); packType.Code = "02"; package.Packaging = packType; PackageType[] pkgArray = { package }; shipment.Package = pkgArray; LabelSpecificationType labelSpec = new LabelSpecificationType(); LabelStockSizeType labelStockSize = new LabelStockSizeType(); labelStockSize.Height = "6"; labelStockSize.Width = "4"; labelSpec.LabelStockSize = labelStockSize; LabelImageFormatType labelImageFormat = new LabelImageFormatType(); LabelDeliveryType labelDel = new LabelDeliveryType(); labelDel.LabelLinksIndicator = ""; labelImageFormat.Code = "GIF"; PackageServiceOptionsType packServiceOptions = new PackageServiceOptionsType(); PackageDeclaredValueType decType = new PackageDeclaredValueType(); decType.CurrencyCode = "USD"; decType.MonetaryValue = http://stackoverflow.com/questions/11365715/s.PackageValue; packServiceOptions.DeclaredValue = decType; package.PackageServiceOptions = packServiceOptions; labelSpec.LabelImageFormat = labelImageFormat; ShipmentTypeShipmentServiceOptions shipServOpt = new ShipmentTypeShipmentServiceOptions(); shipment.ShipmentServiceOptions = shipServOpt; shipmentRequest.LabelSpecification = labelSpec; shipmentRequest.Shipment = shipment; System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); Console.WriteLine(shipmentRequest); shipmentResponse = shpSvc.ProcessShipment(shipmentRequest); }\[/code\]
 
Back
Top