I have WCF web Service and javascript client which connects to this service via AJAX using SOAP 1.2 . What i wanna do is to pass some parameter to tell the AJAX SOAP call to use only one proxy the same as I do it in the WCF Test Client by unchecking the "Start a new proxy" .
And this is my SOAP AJAX call:
DoSoapAjax: function (soapMethodName, data, successHandler, errorHandler, isAsync, currentInstance) {
var service = this;
var soapResult = soapMethodName + "Result";
var soap12WithWsHttpBindRequest ='<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">' +
'<s:Header>' +
'<a:Action s:mustUnderstand="1">' + this.serviceContractNamespace + '/' + this.interfaceName + '/' + soapMethodName + '</a:Action>' +
'<a:MessageID>urn:uuid:605ea0c6-d09b-46bf-b61d-e61b377a135b</a:MessageID>' +
'<a:ReplyTo>' +
'<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>' +
'</a:ReplyTo>' +
'<a:To s:mustUnderstand="1">' + this.tenantAdminService + '</a:To>' +
'</s:Header>' +
'<s:Body>';
if (data == emptyString)
{
soap12WithWsHttpBindRequest +=
'<' + soapMethodName + ' xmlns="' + this.serviceContractNamespace + '" />';
}
else
{
soap12WithWsHttpBindRequest +=
'<' + soapMethodName + ' xmlns="' + this.serviceContractNamespace + '">' +
data +
'</' + soapMethodName + '>';
}
soap12WithWsHttpBindRequest +=
'</s:Body>' +
'</s:Envelope>';
// in order for ajax to work on jQuery 1.8.2 we need to enable the following.
// found this answer on the link : http://stackoverflow.com/questions/9160123/no-transport-error-w-jquery-ajax-call-in-ie
$.support.cors = true;
// variable to save successData
var responseData = null;
// SOAP 1.2 query
var response = $.ajax({
type: "POST",
url: this.tenantAdminService,
data: soap12WithWsHttpBindRequest,
contentType: "application/soap+xml",
dataType: "xml",
processData: false,
async: isAsync,
success: function (data, status, xmlHttpRequest) {
responseData = data;
// inserting all data results into dictionary
var responseResults = {};
// delegating success function
if (successHandler != null)
{
responseResults = service.ParseResponse(soapMethodName, data);
successHandler(responseResults, currentInstance);
}
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
if (errorHandler != null)
{
errorHandler(xmlHttpRequest, textStatus, errorThrown, currentInstance);
}
else if (!isAsync)
{
alert("Error : " + errorThrown);
alert("Error Description : " + xmlHttpRequest.responseText);
}
return;
}
});
if (!isAsync)
{
return service.ParseResponse(soapMethodName, response.responseXML);
}
}
But in practice, transport is almost always handled via HTTP POST requests. This means that Ajax XMLHttpRequest calls can be used to send SOAP requests. The mechanics of SOAP data exchange can appear daunting, especially when compared to the relative ease of data exchange using REST-based web services.
AJAX is not a programming language. AJAX just uses a combination of: A browser built-in XMLHttpRequest object (to request data from a web server) JavaScript and HTML DOM (to display or use the data)
What's AJAX? AJAX stands for Asynchronous JavaScript And XML. In a nutshell, it is the use of the XMLHttpRequest object to communicate with servers. It can send and receive information in various formats, including JSON, XML, HTML, and text files.
Ajax XMLHttpRequest object The core of AJAX is the XMLHttpRequest object (available in client side scripting languages like javascript). The XMLHttpRequest object is used to exchange the data with a live server behind the scenes.
I'll start off by saying I do not know the specific answer to this, but my approach would be to sniff the traffic from your WFC Test Client to see if it is adding any parameters to the call which you could add to your request header on your AJAX call.
Fiddler might do the job though I'm not sure it will catch all http traffic - mostly it's geared to browsers. There are other tools with more or less capability and ease of use, like wire shark, ether, and so on.
I would guess there is some other request parameter outside the SOAP envelope body being transmitted from the test client that you should be able to see. It's the only way I can imagine the test client would be able to communicate this without modifying your SOAP message.
If you can find the name and value, you can add it to your data: parameter as another name-value JSON entity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With