いくつかのデータを Web サービスに投稿しようとしています。明らかに私の側で何かが間違っているので、サンプルコードを送ってくれました。この例では、データを手で入力してサービスに送信することができました。それは機能し、XML データとユーザー/ID でいっぱいのテキスト領域を送信します。データベースをポーリングして未処理の注文を抽出するためのページ設定が既にあります。xml をコンパイルして送信できるように、paypal から新しいページに txnid を送信しようとしています。失敗したメソッドに使用したのと同じコードを削除できると考えました。xml は正しくフォーマットされていますが、SimpleXMLElement 関数を使用しようとすると何か問題があります。これは、以前はテキスト フィールドから渡されたデータを取得し、正常に機能していました。今、私はこのエラーを受け取ります:
PHP致命的なエラー:「文字列をXMLとして解析できませんでした」というメッセージを含むキャッチされない例外「例外」
これがエラーを与えるコードです
include('connect-db.php');
// get the records from the database
if ($result = $mysqli->query("SELECT * FROM paypal_payment_info WHERE txnid = '" .$_GET['txnid']. "'"))
{
// display records if there are records to display
if ($result->num_rows > 0)
{
$row = $result->fetch_object();
// set up a row for each record
$webOrderXML = "<WorkOrder>
<OrderID>127834</OrderID>
<OrderType>test</OrderType>
<ProjectCode> </ProjectCode>
<ProjectShipDate></ProjectShipDate>
<RetailerPO></RetailerPO>
<LineItems>
<LineItem>
<LineNumber>1</LineNumber>
<ProductCode>3PF-DD-SLPGZ6</ProductCode>
<ProductUPC></ProductUPC>
<ItemDescription>Filename</ItemDescription>
<Quantity>1</Quantity>
<ItemSSCC></ItemSSCC>
<FileList>
<Source>/images/" . $row->itemname. str_replace(' ', "", str_replace('"', "", $row->os0)). str_replace('"', "", $row->os1) . str_replace('"', "", $row->os2). ".jpg </Source>
</FileList>
</LineItem>
</LineItems>
<CustomerBillingInfo>
</CustomerBillingInfo>
<CustomerShippingInfo>
<Name>".$row->firstname. " " . $row->lastname."</Name>
<Address1>".$row->street."</Address1>
<Address2> </Address2>
<City>".$row->city."</City>
<State>".$row->state. "</State>
<PostalCode>".$row->zipcode."</PostalCode>
<Country>".$row->country."</Country>
<ShippingMethod>UPS</ShippingMethod>
<ShipAccountNum></ShipAccountNum>
<ShipType>MTH</ShipType>
<DC> </DC>
</CustomerShippingInfo>
<OrderProperties>
</OrderProperties>
</WorkOrder>";
}
// if there are no records in the database, display an alert message
else
{
echo "No results to display!";
}
}
// show an error if there is an issue with the database query
else
{
echo "Error: " . $mysqli->error;
}
// close database connection
$mysqli->close();
//$WebOrderXML = $_POST['webOrderXML'];//orderxml
$sxml = new SimpleXMLElement($WebOrderXML);
$orderidx = $sxml->OrderID;
テキストは同じです。結果の文字列をコピーして他のフォームに貼り付けて投稿できます。それはうまくいきますが、関数がその文字列を好まないため、何かが欠けています。