这是我的客户端代码。虽然调用此函数我遇到400错误的请求错误。任何人都可以帮助我。
var req_params="<?xml version=\"1.0\" encoding=\"utf-8\"?>";
req_params = req_params + "<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/\">";
req_params = req_params + "<soap:Header>";
req_params = req_params + "<UserDetails>";
req_params = req_params + "<Lastname>Abubakar</Lastname>";
req_params = req_params + "<Othernames>Uju, Ayo</Othernames>";
req_params = req_params + "<Email>me@me.com</Email>";
req_params = req_params + "<Phone>08032458829</Phone>";
req_params = req_params + "</UserDetails>";
req_params = req_params + "</soap:Body>";
req_params = req_params + "</soap:Envelope>";
console.log(req_params);
$.ajax({
type: "POST",
url: "http://testservices.interswitchng.com/quicktellerservice/quickteller.svc/CreateUser",
data: req_params,
processData:false,
contentType: "text/xml; charset=\"utf-8\"",
dataType: "xml",
success: function (data) {
console.log(data);
},
error: function (xhr, status, error) {
alert(error);
}
});
答案 0 :(得分:0)
原因是,如果不修改您正在使用的Web服务,则无法进行跨域调用。如果你谷歌“jquery跨域ajax”,你可以找到更多相关信息。
在这里,您将找到跨域XML调用的示例:http://www.cypressnorth.com/blog/programming/cross-domain-ajax-request-with-xml-response-for-iefirefoxchrome-safari-jquery/