我想從Webservice(Soap)獲取數據,但它並不成功。我的服務在這裏http://icafe.ipos.vn/WSUitility/evsServiceUtility.svc?wsdl
使用jQuery來請求服務,代碼如下如何通過jquery從Soap服務獲取數據?
var soap = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<Test xmlns=''>" +
"</Test>" +
"</soap:Body>" +
"</soap:Envelope>";
$.ajax({
url: 'http://icafe.ipos.vn/WSUitility/evsServiceUtility.svc?wsdl',
method: 'post',
data: soap,
contentType: "text/xml",
dataType: "xml",
beforeSend: function (xhr) {
xhr.setRequestHeader("SOAPAction", "urn:evsServiceUtility/Test1");
},
crossDomain: true,
success: function(SOAPResponse) {
alert('ok');
},
error: function(SOAPResponse) {
alert('no ok');
}
});
我的服務:
public string Test()
{
try
{
return "Successfull!";
}
catch (Exception ex)
{
return ex.Message;
}
}
我spended很多很多次搜索並嘗試了很多解決方案,但它不工作。
任何人都可以幫助我嗎?
你有什麼異常? –
我得到代碼響應400錯誤的請求。 –