在 Javascript 中发布 SOAP

Publish SOAP in a Javascript

本文关键字:SOAP Javascript      更新时间:2023-09-26

有人看到我在这里穿什么吗?我试图在我的asp网站中使用此脚本。$z:value[article.number] 是我在 ASP 中的 art.number。当我点击我的文章时,我的意图会看到图片。

此致敬意弗兰克

<script type="text/javascript">
var symbol = "MSFT"; 
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://produktinfo.byggtjeneste.no/ProduktInfo.asmx?op=HentBildeLenkeTyped",true);
xmlhttp.onreadystatechange=function() {
 if (xmlhttp.readyState == 4) {
  alert(xmlhttp.responseText);
  var json = XMLObjectifier.xmlToJSON(xmlhttp.responseXML);
  var result = json.Body[0].HentBildeLenkeTypedResponse[0].HentBildeLenkeTypedResult[0].Text;
  json = XMLObjectifier.xmlToJSON(XMLObjectifier.textToXML(result));
  alert(SModulNr + ' ProduktInfo: $' + json.Stock[0].Last[0].Text); 
 }
}
xmlhttp.setRequestHeader("SOAPAction", "http://produktinfo.byggtjeneste.no/HentBildeLenkeTyped");
xmlhttp.setRequestHeader("Content-Type", "text/xml");
var xml = '<?xml version="1.0" encoding="utf-8"?>' +
 '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' + 
   '<soap:Body> ' +
     '<HentBildeLenkeTyped xmlns="http://produktinfo.byggtjeneste.no/"> ' +
       '<sModulNr> + $z:value[article.number] + </sModulNr> '+
       '<iSize>xlarge</iSize> '+
     '</HentBildeLenkeTyped> ' +
   '</soap:Body> ' +
 '</soap:Envelope>';
xmlhttp.send(xml);
</script>

这是我的提供者的原始文件。

POST /ProduktInfo.asmx HTTP/1.1
Host: produktinfo.byggtjeneste.no
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <HentBildeLenkeTyped xmlns="http://produktinfo.byggtjeneste.no/">
      <sModulNr>string</sModulNr>
      <iSize>None or small or large or xlarge or original or largeThumbnail</iSize>
    </HentBildeLenkeTyped>
  </soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <HentBildeLenkeTypedResponse xmlns="http://produktinfo.byggtjeneste.no/">
      <HentBildeLenkeTypedResult>string</HentBildeLenkeTypedResult>
    </HentBildeLenkeTypedResponse>
  </soap12:Body>
</soap12:Envelope>

此行

'<sModulNr>$z:value[article.number]</sModulNr>  '

是你出错的地方。 您实际上是在请求值"$z:value[article.number]"而不是您想要的文章编号。

我不清楚您发布的内容$z是什么,但您可能想要更多类似的东西

'<sModulNr>' + $z:value[article.number] + '</sModulNr>'