Also,
die
XML wird tatsächlich von IE nicht akzeptiert, obwohl sie so im
SDK steht. Es ist so, dass der erste Part <AccessRequest> und der zweite Part <ShipmentConfirmRequest> nicht zusammen vorkommen dürfen, sonst meldet IE Nur ein Element auf höchster Stufe erlaubt. Also in zwei verschiedene
XML gepackt, dann gehts.
Den Code habe ich entsprechend geändert und die Requests aufgeteilt:
Delphi-Quellcode:
procedure TForm1.Button10Click(Sender: TObject);
var
request: TStrings;
response: TStringStream;
begin
request := TStringlist.Create;
response := TStringStream.Create('
');
request.Add('
<?xml version="1.0"?>');
request.Add('
<AccessRequest xml:lang="en-US">');
request.Add('
<AccessLicenseNumber>5BC0971811XXXXX</AccessLicenseNumber>');
request.Add('
<UserId>smartmod</UserId>');
request.Add('
<Password>xxxxxxx</Password>');
request.Add('
</AccessRequest>');
IDHttp1.Post('
https://wwwcie.ups.com/ups.app/xml/ShipConfirm', request, response);
request.Clear;
response.Clear;
request.Add('
<?xml version="1.0"?>');
request.Add('
<ShipmentConfirmRequest xml:lang="en-US">');
request.Add('
<Request>');
request.Add('
<TransactionReference>');
request.Add('
<CustomerContext>Ship Confirm / nonvalidate</CustomerContext>');
request.Add('
<XpciVersion>1.0001</XpciVersion>');
request.Add('
</TransactionReference>');
request.Add('
<RequestAction>ShipConfirm</RequestAction>');
request.Add('
<RequestOption>nonvalidate</RequestOption>');
request.Add('
</Request>');
request.Add('
<LabelSpecification>');
request.Add('
<LabelPrintMethod>');
request.Add('
<Code>GIF</Code>');
request.Add('
</LabelPrintMethod>');
request.Add('
<HTTPUserAgent>Mozilla/5.0</HTTPUserAgent>');
request.Add('
<LabelImageFormat>');
request.Add('
<Code>GIF</Code>');
request.Add('
</LabelImageFormat>');
request.Add('
</LabelSpecification>');
request.Add('
<Shipment>');
request.Add('
<Description>DescriptionofGoodsTest</Description>');
request.Add('
<Shipper>');
request.Add('
<Name>Smartmod</Name>');
request.Add('
<AttentionName>Jan Petermann</AttentionName>');
request.Add('
<PhoneNumber>06996860470</PhoneNumber>');
request.Add('
<ShipperNumber>W2217V</ShipperNumber>');
request.Add('
<Address>');
request.Add('
<AddressLine1>Bertha-von-Suttner-Ring 8</AddressLine1>');
request.Add('
<City>Frankfurt am Main</City>');
request.Add('
<PostalCode>60598</PostalCode>');
request.Add('
<CountryCode>DE</CountryCode>');
request.Add('
</Address>');
request.Add('
</Shipper>');
request.Add('
<ShipTo>');
request.Add('
<CompanyName>Smartmod</CompanyName>');
request.Add('
<AttentionName>Jan Petermann</AttentionName>');
request.Add('
<PhoneNumber>069686440</PhoneNumber>');
request.Add('
<Address>');
request.Add('
<AddressLine1>Bertha-von-Suttner-Ring 8</AddressLine1>');
request.Add('
<PostalCode>60598</PostalCode>');
request.Add('
<City>Frankfurt</City>');
request.Add('
<CountryCode>DE</CountryCode>');
request.Add('
</Address>');
request.Add('
</ShipTo>');
request.Add('
<ShipFrom>');
request.Add('
<CompanyName>ShipFromCompanyName</CompanyName>');
request.Add('
<AttentionName>Jan Petermann</AttentionName>');
request.Add('
<PhoneNumber>06996860470</PhoneNumber>');
request.Add('
<ShipperNumber>W2217V</ShipperNumber>');
request.Add('
<Address>');
request.Add('
<AddressLine1>Bertha-von-Suttner-Ring 8</AddressLine1>');
request.Add('
<City>Frankfurt am Main</City>');
request.Add('
<PostalCode>60598</PostalCode>');
request.Add('
<CountryCode>DE</CountryCode>');
request.Add('
</Address>');
request.Add('
</ShipFrom>');
request.Add('
<PaymentInformation>');
request.Add('
<Prepaid>');
request.Add('
<BillShipper>');
request.Add('
<AccountNumber>W2217V</AccountNumber>');
request.Add('
</BillShipper>');
request.Add('
</Prepaid>');
request.Add('
</PaymentInformation>');
request.Add('
<Service>');
request.Add('
<Code>07</Code>');
request.Add('
</Service>');
request.Add('
<Package>');
request.Add('
<PackagingType>');
request.Add('
<Code>02</Code>');
request.Add('
</PackagingType>');
request.Add('
<Dimensions>');
request.Add('
<UnitOfMeasurement>');
request.Add('
<Code>CM</Code>');
request.Add('
</UnitOfMeasurement>');
request.Add('
<Length>60</Length>');
request.Add('
<Width>7</Width>');
request.Add('
<Height>5</Height>');
request.Add('
</Dimensions>');
request.Add('
<PackageWeight>');
request.Add('
<UnitOfMeasurement>');
request.Add('
<Code>KGS</Code>');
request.Add('
</UnitOfMeasurement>');
request.Add('
<Weight>3.0</Weight>');
request.Add('
</PackageWeight>');
request.Add('
</Package>');
request.Add('
</Shipment>');
request.Add('
</ShipmentConfirmRequest>');
Memo1.Text:=IDHttp1.Post('
https://wwwcie.ups.com/ups.app/xml/ShipConfirm', request);
end;
Nach wie vor kommt "Connection closed gracefully" und kein Response im Memo1.
Könnte mir vielleicht jemand, der sowas schonmal gemacht hat, einen kurzen Beispielcode schreiben, wie ich den Inhalt einer
XML Datei an einen Server poste und das Ergebnis in einem Memo ausgeben lasse?
Also dass was ich hier versuche, nur einfach komplett neu und nicht von meinem laienhaften Code ausgehend?
Das wär klasse.
Danke schonmal!