我想使用jQuery Ajax調用asmx服務。使用jQuery Ajax發送肥皂信封的自定義標題
POST /YderWS.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://scandihealth.com/iwebservices/HentKommuner"
<?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:Header>
<AuthHeader xmlns="http://scandihealth.com/iwebservices/">
<PartnerID>string</PartnerID>
<SubPartnerID>string</SubPartnerID>
<SubPartnerType>string</SubPartnerType>
</AuthHeader>
</soap:Header>
<soap:Body>
<HentKommuner xmlns="http://scandihealth.com/iwebservices/" />
</soap:Body>
</soap:Envelope>
上面是我需要發送到服務的SOAP 1.1請求。我使用下面的調用來設置自定義肥皂標題。但我的請求失敗。任何人都可以爲我調試下面的代碼,讓我知道我需要做什麼?
var authHeader = "<PartnerID>SCTEST001</PartnerID> <SubPartnerID>001</SubPartnerID> <SubPartnerType>S</SubPartnerType>";
//Call the page method
$.ajax({
type: "GET",
url: servicename + "/" + functionName,
beforeSend: function (xhr) {
xhr.setRequestHeader('AuthHeader', authHeader);
},
success: successFn,
error: errorFn
});
編輯 * 請讓我知道,如果需要更多的信息來回答這個問題。 *
你得到什麼錯誤原因?它可能很容易成爲一個跨域問題。 –