Ho un servizio web WCF e un client javascript che si connette a questo servizio tramite AJAX utilizzando SOAP 1.2. Quello che voglio fare è passare alcuni parametri per dire alla chiamata SOAP AJAX a utilizzare solo un proxy lo stesso che faccio nel client di test WCF deselezionando "Avvia un nuovo proxy". Come utilizzare un proxy in javascript AJAX utilizzando SOAP come WCF Test Client usa
E questo è il mio SOAP chiamata AJAX:
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);
}
}
E 'questo il tuo server o un servizio SOAP di terze parti? Mi sto chiedendo a causa dei problemi del sito incrociato se stai facendo in modo che il cliente pubblichi xml tramite questa funzione a SOAP di terze parti. Credo che la maggior parte dei browser non ti consenta di pubblicare xml su una terza parte direttamente tramite js dalla tua pagina web di origine. Dal tuo schermo wcf, lo prendo è interno. Quindi cosa intendi per proxy quindi per il client del browser? – williambq
@williambq Grazie per il tuo commento. Questo è il mio server.non una terza parte. – liorafar
Quindi, penso che stai cercando di ottenere un proxy Singleton sul posto? Quindi ogni richiesta crea una nuova istanza del proxy quando viene chiamato? – williambq