私は成功コールバック内で次のコードを使用して、AJAX応答からSOAP XMLデータを抽出するためにjQueryを使用しています。参考のためにhttps://api.jquery.com/jQuery.parseXML/の例を使用しています。私が$.parseXML()
関数を使用していない理由は、data
が既に解析された応答であり、再度解析してnull応答を生成するためです。jQueryでSOAP XMLを抽出できません
(curShipmentはJSON形式で必要な情報を格納するための変数であり、あなたはそれを無視することができます)私の成功コールバック:このコードは、もともとクロームChromeで先週、かつて働いていた
success: function(data) {
var $xml = $(data);
if ($xml.find("error").text() != "") {
resetUI();
alertMessage($xml.find("error").text(), "danger");
} else {
curShipment.labelId = $xml.find("id").first().text();
curShipment.loo_wb = $xml.find('value').first().text();
curShipment.senderName = $xml.find('pickup_name').text();
curShipment.consigneeName = $xml.find('delivery_name').text();
saveShipment();
}
はV60に更新もはやそれはありません。私はFirefoxやInternet Explorerで動作しなかったという事実以外は、Chromeのバグでこれを責めるだろう。だから、明らかに、私のコードには、以前のバージョンでChromeが何らかの形で取り組んでいたという問題があります。アドバイスをいただければ幸いです.JQueryの経験はほとんどありません。
はここconsole.log(data)
が(それはそう長くごめんだ - 私は実際にそれの半分を削除)です:私はconsole.log($xml)
を行うと、オブジェクトを展開すると
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:processShipmentResponse xmlns:ns="http://ws.business.uss.transforce.ca">
<ns:return xsi:type="ax25:ProcessShipmentRs" xmlns:ax27="http://dto.uss.transforce.ca/xsd" xmlns:ax25="http://ws.business.uss.transforce.ca/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax25:error xsi:nil="true"/>
<ax25:processShipmentResult xsi:type="ax27:ProcessShipmentResult">
<ax27:shipment xsi:type="ax27:Shipment">
<ax27:billed_weight>21.0</ax27:billed_weight>
<ax27:billed_weight_unit>L</ax27:billed_weight_unit>
<ax27:collect_shipper_num/>
<ax27:consolidation_type/>
<ax27:courier>L</ax27:courier>
<ax27:delivery_address_id/>
<ax27:delivery_address_line_1>123 MAIN ST</ax27:delivery_address_line_1>
<ax27:delivery_address_line_2>STE 200</ax27:delivery_address_line_2>
<ax27:delivery_address_line_3/>
<ax27:delivery_city>MISSISSAUGA</ax27:delivery_city>
<ax27:delivery_country>CA</ax27:delivery_country>
<ax27:delivery_email>[email protected]</ax27:delivery_email>
<ax27:delivery_extension>1234</ax27:delivery_extension>
<ax27:delivery_name>COMPANY NAME HERE</ax27:delivery_name>
<ax27:delivery_phone>9055551212</ax27:delivery_phone>
<ax27:delivery_postal_code>L5R3R3</ax27:delivery_postal_code>
<ax27:delivery_province>ON</ax27:delivery_province>
<ax27:delivery_residential>false</ax27:delivery_residential>
<ax27:dimension_unit>I</ax27:dimension_unit>
<ax27:estimated_delivery_date xsi:nil="true"/>
<ax27:freight_charge>0.00</ax27:freight_charge>
<ax27:fuel_surcharge>1.20</ax27:fuel_surcharge>
<ax27:id>10000734</ax27:id>
<ax27:inserted_on>2017-04-07T11:03:30.508-04:00</ax27:inserted_on>
<ax27:manifest_num xsi:nil="true"/>
<ax27:packages xsi:type="ax27:Package">
<ax27:billed_weight>20.5</ax27:billed_weight>
<ax27:dim_weight>0.0</ax27:dim_weight>
<ax27:dim_weight_flag>false</ax27:dim_weight_flag>
<ax27:id>10005262</ax27:id>
<ax27:inserted_on>2017-04-07T11:03:30.508-04:00</ax27:inserted_on>
<ax27:min_weight_flag>false</ax27:min_weight_flag>
<ax27:package_info_str xsi:type="ax27:PackageInfoStr">
<ax27:id>10002317</ax27:id>
<ax27:inserted_on>2017-04-07T11:03:31.241-04:00</ax27:inserted_on>
<ax27:name>PIN</ax27:name>
<ax27:updated_on>2017-04-07T11:03:31.241-04:00</ax27:updated_on>
<ax27:value>LSHA00007014</ax27:value>
</ax27:package_info_str>
<ax27:package_num>0</ax27:package_num>
<ax27:package_reference>0</ax27:package_reference>
<ax27:reported_weight>20.5</ax27:reported_weight>
<ax27:updated_on>2017-04-07T11:03:31.241-04:00</ax27:updated_on>
</ax27:packages>
<ax27:pickup_address_line_1>5555 DIXIE RD</ax27:pickup_address_line_1>
<ax27:pickup_address_line_2>BUILDING 2</ax27:pickup_address_line_2>
<ax27:pickup_address_line_3>STE 500</ax27:pickup_address_line_3>
<ax27:pickup_city>MISSISSAUGA</ax27:pickup_city>
<ax27:pickup_email>[email protected]</ax27:pickup_email>
<ax27:pickup_extension>6162</ax27:pickup_extension>
<ax27:pickup_name>LOOMIS EXPRESS</ax27:pickup_name>
<ax27:pickup_phone>9054528769</ax27:pickup_phone>
<ax27:pickup_postal_code>L4W1E6</ax27:pickup_postal_code>
<ax27:pickup_province>ON</ax27:pickup_province>
<ax27:proforma xsi:nil="true"/>
<ax27:reported_weight_unit>L</ax27:reported_weight_unit>
<ax27:service_type>DD</ax27:service_type>
<ax27:shipment_info_str xsi:type="ax27:ShipmentInfoStr">
<ax27:id>10005201</ax27:id>
<ax27:inserted_on>2017-04-07T11:03:31.194-04:00</ax27:inserted_on>
<ax27:name>CODE</ax27:name>
<ax27:updated_on>2017-04-07T11:03:31.241-04:00</ax27:updated_on>
<ax27:value>AA</ax27:value>
</ax27:shipment_info_str>
<ax27:shipment_info_str xsi:type="ax27:ShipmentInfoStr">
<ax27:id>10005202</ax27:id>
<ax27:inserted_on>2017-04-07T11:03:31.194-04:00</ax27:inserted_on>
<ax27:name>SERVICE_LABEL</ax27:name>
<ax27:updated_on>2017-04-07T11:03:31.241-04:00</ax27:updated_on>
<ax27:value>GRD</ax27:value>
</ax27:shipment_info_str>
<ax27:shipment_info_str xsi:type="ax27:ShipmentInfoStr">
<ax27:id>10005203</ax27:id>
<ax27:inserted_on>2017-04-07T11:03:31.194-04:00</ax27:inserted_on>
<ax27:name>BRANCH_CITY</ax27:name>
<ax27:updated_on>2017-04-07T11:03:31.241-04:00</ax27:updated_on>
<ax27:value>BRAMPTON</ax27:value>
</ax27:shipment_info_str>
<ax27:shipment_info_str xsi:type="ax27:ShipmentInfoStr">
<ax27:id>10005204</ax27:id>
<ax27:inserted_on>2017-04-07T11:03:31.241-04:00</ax27:inserted_on>
<ax27:name>SIN</ax27:name>
<ax27:updated_on>2017-04-07T11:03:31.241-04:00</ax27:updated_on>
<ax27:value>LSHA00007014</ax27:value>
</ax27:shipment_info_str>
<ax27:shipment_status>R</ax27:shipment_status>
<ax27:shipper_num>HB4499</ax27:shipper_num>
<ax27:shipping_date>20170407</ax27:shipping_date>
<ax27:tax_charge_1>1.26</ax27:tax_charge_1>
<ax27:tax_charge_2>0.00</ax27:tax_charge_2>
<ax27:tax_code_1>GST</ax27:tax_code_1>
<ax27:tax_code_2/>
<ax27:transit_time>1</ax27:transit_time>
<ax27:transit_time_guaranteed>false</ax27:transit_time_guaranteed>
<ax27:updated_on>2017-04-07T11:03:31.241-04:00</ax27:updated_on>
<ax27:user_id>[email protected]</ax27:user_id>
<ax27:voided>false</ax27:voided>
<ax27:zone>1</ax27:zone>
</ax27:shipment>
</ax25:processShipmentResult>
</ns:return>
</ns:processShipmentResponse>
</soapenv:Body>
</soapenv:Envelope>
が、これは私が見たものである。
documentElement
をsoapエンベロープとして展開し、そのオブジェクトの下で、innerHTML
要素内の残りのXMLを見ることができます。
ありがとうございます!
私の最初の推測は名前空間の問題です。あなたのコードはSOAP XMLの間に名前空間を使用しません。 – Sirko
'$ xml.find(" ax27:id ")。' id'の代わりにfirst()。text(); 'を試してください。 –
提案していただきありがとうございます。私は名前空間を追加しましたが、私はまだ同じ問題を抱えています。 'console.log($ xml.find(" ax27:delivery_name ")。text());'しようとすると、空白の応答が返されます。 –