关于type.2.4.d的Fedex API XML错误

时间:2017-04-18 02:52:21

标签: xml soap fedex

我尝试使用ETD(ELECTRONIC_TRADE_DOCUMENTS)创建标签和发票。 我可以打印标签但是当我在XML中添加发票信息时,我收到xml错误。

以下是请求。

{ 'soap:Envelope': 
   { '$': 
      { 'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/',
        'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
        'xmlns:ns': 'http://fedex.com/ws/ship/v15' },
     'soap:Body': 
      { 'ns:ProcessShipmentRequest': 
         { '$': 
            { 'xmlns:ns': 'http://fedex.com/ws/ship/v15',
              xmlns: 'http://fedex.com/ws/ship/v15' },
           'ns:WebAuthenticationDetail': 
            { 'ns:UserCredential': 
               { 'ns:Key': 'key',
                 'ns:Password': 'password' } },
           'ns:ClientDetail': 
            { 'ns:AccountNumber': 'account',
              'ns:MeterNumber': 'meter' },
           'ns:Version': 
            { 'ns:ServiceId': 'ship',
              'ns:Major': '15',
              'ns:Intermediate': '0',
              'ns:Minor': '0' },
           'ns:RequestedShipment': 
            { 'ns:ShipTimestamp': '2017-04-19T02:34:23.563Z',
              'ns:DropoffType': 'REGULAR_PICKUP',
              'ns:ServiceType': 'INTERNATIONAL_ECONOMY',
              'ns:PackagingType': 'YOUR_PACKAGING',
              'ns:PreferredCurrency': 'JYE',
              'ns:Shipper': 
               { 'ns:Contact': 
                  { 'ns:PersonName': 'PLAYAUTO WARE',
                    'ns:PhoneNumber': '01012345678' },
                 'ns:Address': 
                  { 'ns:StreetLines': [ '2-Chome, Kozu', 'Chuo-ku, Osaka' ],
                    'ns:City': 'Osaka',
                    'ns:PostalCode': '542-0072',
                    'ns:CountryCode': 'JP' } },
              'ns:Recipient': 
               { 'ns:Contact': 
                  { 'ns:PersonName': 'Li Bing Lin',
                    'ns:PhoneNumber': '302 839 2008' },
                 'ns:Address': 
                  { 'ns:StreetLines': [ '19 Lukens Dr', '-' ],
                    'ns:City': 'New Castle',
                    'ns:StateOrProvinceCode': 'DE',
                    'ns:PostalCode': '19720-2787',
                    'ns:CountryCode': 'US' } },
              'ns:ShippingChargesPayment': 
               { 'ns:PaymentType': 'SENDER',
                 'ns:Payor': { 'ns:ResponsibleParty': { 'ns:AccountNumber': '426072840' } } },
              'ns:CustomsClearanceDetail': 
               { 'ns:DutiesPayment': 
                  { 'ns:PaymentType': 'SENDER',
                    'ns:Payor': 
                     { 'ns:ResponsibleParty': 
                        { 'ns:AccountNumber': '426072840',
                          'ns:Tins': { 'ns:TinType': 'BUSINESS_STATE', 'ns:Number': 'XXXX' },
                          'ns:Contact': { 'ns:ContactId': '12345', 'ns:PersonName': 'XXXX' } } } },
                 'ns:DocumentContent': 'DOCUMENTS_ONLY',
                 'ns:CustomsValue': { 'ns:Currency': 'USD', 'ns:Amount': '200.68' },
                 'ns:CommercialInvoice': { 'ns:TermsOfSale': 'FOB' },
                 'ns:Commodities': 
                  { 'ns:NumberOfPieces': '1',
                    'ns:Description': 'wefwef KR undefined undefined',
                    'ns:CountryOfManufacture': 'US',
                    'ns:Weight': { 'ns:Units': 'KG', 'ns:Value': '0' },
                    'ns:Quantity': '1',
                    'ns:QuantityUnits': 'cm',
                    'ns:UnitPrice': { 'ns:Currency': 'USD', 'ns:Amount': '200.68' },
                    'ns:CustomsValue': { 'ns:Currency': 'USD', 'ns:Amount': '200.68' } },
                 'ns:ExportDetail': { 'ns:ExportComplianceStatement': '30.37(f)' } },
              'ns:LabelSpecification': 
               { 'ns:LabelFormatType': 'COMMON2D',
                 'ns:ImageType': 'PDF',
                 'ns:LabelStockType': 'PAPER_4X6' },
              'ns:RateRequestTypes': 'LIST',
              'ns:PackageCount': '1',
              'ns:RequestedPackageLineItems': 
               { 'ns:SequenceNumber': '1',
                 'ns:Weight': { 'ns:Units': 'KG', 'ns:Value': '3' },
                 'ns:CustomerReferences': 
                  { 'ns:CustomerReferenceType': 'CUSTOMER_REFERENCE',
                    'ns:Value': '1234' } } }
           } } } } } }

当我发送此请求时,我会收到我想要的结果。 但我必须收到ETD和发票。 所以我发送了带有ShippingDocumentSpecification和SpecialServicesRequested参数的请求。

以下是请求添加。

{ 'soap:Envelope': 
   { '$': 
      { 'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/',
        'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
        'xmlns:ns': 'http://fedex.com/ws/ship/v15' },
     'soap:Body': 
      { 'ns:ProcessShipmentRequest': 
         { '$': 
            { 'xmlns:ns': 'http://fedex.com/ws/ship/v15',
              xmlns: 'http://fedex.com/ws/ship/v15' },
           'ns:WebAuthenticationDetail': 
            { 'ns:UserCredential': 
               { 'ns:Key': 'Key',
                 'ns:Password': 'Password' } },
           'ns:ClientDetail': 
            { 'ns:AccountNumber': 'Account',
              'ns:MeterNumber': 'Meter' },
           'ns:Version': 
            { 'ns:ServiceId': 'ship',
              'ns:Major': '15',
              'ns:Intermediate': '0',
              'ns:Minor': '0' },
           'ns:RequestedShipment': 
            { 'ns:ShipTimestamp': '2017-04-19T02:46:55.862Z',
              'ns:DropoffType': 'REGULAR_PICKUP',
              'ns:ServiceType': 'INTERNATIONAL_ECONOMY',
              'ns:PackagingType': 'YOUR_PACKAGING',
              'ns:PreferredCurrency': 'JYE',
              'ns:Shipper': 
               { 'ns:Contact': 
                  { 'ns:PersonName': 'PLAYAUTO WARE',
                    'ns:PhoneNumber': '01012345678' },
                 'ns:Address': 
                  { 'ns:StreetLines': [ '2-Chome, Kozu', 'Chuo-ku, Osaka' ],
                    'ns:City': 'Osaka',
                    'ns:PostalCode': '542-0072',
                    'ns:CountryCode': 'JP' } },
              'ns:Recipient': 
               { 'ns:Contact': 
                  { 'ns:PersonName': 'Li Bing Lin',
                    'ns:PhoneNumber': '302 839 2008' },
                 'ns:Address': 
                  { 'ns:StreetLines': [ '19 Lukens Dr', '-' ],
                    'ns:City': 'New Castle',
                    'ns:StateOrProvinceCode': 'DE',
                    'ns:PostalCode': '19720-2787',
                    'ns:CountryCode': 'US' } },
              'ns:ShippingChargesPayment': 
               { 'ns:PaymentType': 'SENDER',
                 'ns:Payor': { 'ns:ResponsibleParty': { 'ns:AccountNumber': '426072840' } } },
              'ns:CustomsClearanceDetail': 
               { 'ns:DutiesPayment': 
                  { 'ns:PaymentType': 'SENDER',
                    'ns:Payor': 
                     { 'ns:ResponsibleParty': 
                        { 'ns:AccountNumber': '426072840',
                          'ns:Tins': { 'ns:TinType': 'BUSINESS_STATE', 'ns:Number': 'XXXX' },
                          'ns:Contact': { 'ns:ContactId': '12345', 'ns:PersonName': 'XXXX' } } } },
                 'ns:DocumentContent': 'DOCUMENTS_ONLY',
                 'ns:CustomsValue': { 'ns:Currency': 'USD', 'ns:Amount': '200.68' },
                 'ns:CommercialInvoice': { 'ns:TermsOfSale': 'FOB' },
                 'ns:Commodities': 
                  { 'ns:NumberOfPieces': '1',
                    'ns:Description': 'wefwef KR undefined undefined',
                    'ns:CountryOfManufacture': 'US',
                    'ns:Weight': { 'ns:Units': 'KG', 'ns:Value': '0' },
                    'ns:Quantity': '1',
                    'ns:QuantityUnits': 'cm',
                    'ns:UnitPrice': { 'ns:Currency': 'USD', 'ns:Amount': '200.68' },
                    'ns:CustomsValue': { 'ns:Currency': 'USD', 'ns:Amount': '200.68' } },
                 'ns:ExportDetail': { 'ns:ExportComplianceStatement': '30.37(f)' } },
              'ns:LabelSpecification': 
               { 'ns:LabelFormatType': 'COMMON2D',
                 'ns:ImageType': 'PDF',
                 'ns:LabelStockType': 'PAPER_4X6' },
              'ns:RateRequestTypes': 'LIST',
              'ns:PackageCount': '1',
              'ns:RequestedPackageLineItems': 
               { 'ns:SequenceNumber': '1',
                 'ns:Weight': { 'ns:Units': 'KG', 'ns:Value': '3' },
                 'ns:CustomerReferences': 
                  { 'ns:CustomerReferenceType': 'CUSTOMER_REFERENCE',
                    'ns:Value': '1234' } },
              'ns:ShippingDocumentSpecification': 
               { 'ns:ShippingDocumentTypes': 'COMMERCIAL_INVOICE',
                 'ns:CommercialInvoiceDetail': 
                  { 'ns:Format': 
                     { 'ns:StockType': 'PAPER_LETTER',
                       'ns:ImageType': 'PDF',
                       'ns:ImageTypeSpecified': 'true',
                       'ns:StockTypeSpecified': 'true' } } },
              'ns:SpecialServicesRequested': 
               { 'ns:SpecialServiceTypes': 'ELECTRONIC_TRADE_DOCUMENTS',
                 'ns:EtdDetail': { 'ns:RequestedDocumentCopies': 'COMMERCIAL_INVOICE' } } } } } } 

我收到错误

faultcode=SOAP-ENV:Server, xml:lang=en, $value=Fault, cause=UnrecoverableClientError, code=SchemaError, desc=validation failure for ProcessShipmentRequest Error:cvc-complex-type.2.4.a: Invalid content was found starting with element 'ns:ShippingDocumentSpecification'. One of '{"http://fedex.com/ws/ship/v15":RequestedPackageLineItems}' is expected.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'ns:ImageType'. One of '{"http://fedex.com/ws/ship/v15":ProvideInstructions, "http://fedex.com/ws/ship/v15":OptionsRequested, "http://fedex.com/ws/ship/v15":Localization, "http://fedex.com/ws/ship/v15":CustomDocumentIdentifier}' is expected.

我不明白这个错误。 我认为当XML顺序不正确或未定义时,会出现此错误。 但我还没有解决这个问题。

如何解决此问题?

API文档:http://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201408/ShipServiceWSDLGuide_v2014.pdf

WSDL:https://github.com/uh-opensource/node-shipping-fedex/blob/master/lib/wsdl/ShipService_v15.wsdl

0 个答案:

没有答案