This project is read-only.

WCF

Feb 2, 2008 at 11:26 PM
Is there any problem using this with WCF instead of ASMX web services?
Feb 4, 2008 at 11:34 PM
Uhmmm.... im just trying it now with a WCF service and i am getting this error:

The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

Could be the problem the wsdl:import that WCF generate??

This is the WCF wsdl with witch im having problems:
http://beta.verimas.com/api/v2.0/auth.svc?wsdl

Any Idea?

Thanks for all.
Feb 8, 2008 at 10:44 PM
I found this on Code Project under the title of: Won't work with WCF

in WCF, Soap action is not always "namespace/MethodName"
you have to use
var actionNode = wsdl.selectNodes( "//wsdl:binding/wsdl:operation@name='" + method + "'/soap:operation" ).item(0);
var soapAction = actionNode.attributes.getNamedItem( "soapAction" ).value;

in SOAPClient._sendSoapRequest, right after the first line ( var ns = ... )
to get the real soap action.

The link is shown below.
http://www.codeproject.com/KB/ajax/JavaScriptSOAPClient.aspx?df=90&forumid=260173&exp=0&select=1811224&fid=260173&mpp=25&noise=3&sort=Position&view=Quick&fr=26
Feb 9, 2008 at 12:42 AM
I tried it, and it worked perfectly! Here is the full code in the only changed method.

SOAPClient._sendSoapRequest = function(url, method, parameters, async, callback, wsdl)
{
// get namespace
var ns = (wsdl.documentElement.attributes"targetNamespace" + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes"targetNamespace".value;
var actionNode = wsdl.selectNodes( "//wsdl:binding/wsdl:operation@name='" + method + "'/soap:operation" ).item(0);
var soapAction = actionNode.attributes.getNamedItem( "soapAction" ).value;

// build SOAP request
var sr =
"<?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:Body>" +
"<" + method + " xmlns=\"" + ns + "\">" +
parameters.toXml() +
"</" + method + "></soap:Body></soap:Envelope>";
// send request
var xmlHttp = SOAPClient._getXmlHttp();
if (SOAPClient.userName && SOAPClient.password){
xmlHttp.open("POST", url, async, SOAPClient.userName, SOAPClient.password);
// Some WS implementations (i.e. BEA WebLogic Server 10.0 JAX-WS) don't support Challenge/Response HTTP BASIC, so we send authorization headers in the first request
xmlHttp.setRequestHeader("Authorization", "Basic " + SOAPClient._toBase64(SOAPClient.userName + ":" + SOAPClient.password));
}
else
xmlHttp.open("POST", url, async);
var soapaction;
if(soapAction != null && soapAction != "") soapaction = soapAction;
else soapaction = ((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + method;
xmlHttp.setRequestHeader("SOAPAction", soapaction);
xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
if(async)
{
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
SOAPClient._onSendSoapRequest(method, async, callback, wsdl, xmlHttp);
}
}
xmlHttp.send(sr);
if (!async)
return SOAPClient._onSendSoapRequest(method, async, callback, wsdl, xmlHttp);
}
Jul 10, 2009 at 12:22 PM

Hi Dewey!

I'm trying to fix this code but I have a problem with this line:

var actionNode = wsdl.selectNodes( "//wsdl:binding/wsdl:operation@name='" + method + "'/soap:operation" ).item(0);

I have the next error:

Image Hosted by ImageShack.us



Could you tell me what is the problem please?

 

Thanks for all