When working with some specific Java based platforms there was a specific problem with the automatic generated WSDL descriptions, because they use an external schema for defining the structure of the passed data:
<wsdl:types> <xsd:schema targetNamespace="http://tempuri.org/Imports"> <xsd:import schemaLocation=http://localhost/AJAXEngine/S02_AJAXCoreSamples/CalcFactors.svc?xsd=xsd0
namespace="http://tempuri.org/" /> ... </xsd:schema> </wsdl:types>
When adopting the WCF .svc services this kind of using WSDL and XML schema definitions can be found too.
<!-- importing an external schema –>
<xsl:variable name="inputElementName" select="substring-after(wsdl:part/@element, ':')" />
<xsl:variable name="doc" select="document(@schemaLocation)"/>
<xsl:with-param name="name" select="@name" />
<xsl:with-param name="type" select="@type" />
In the .NET environment the document function will not work for security reasons without some special instructions for the xslt transform. When passing a XmlUrlResolver when loading the xslt file the document() function can retrieve the referenced external document.
XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials = CredentialCache.DefaultCredentials; XslCompiledTransform xsl = new XslCompiledTransform(); xsl.Load(Server.MapPath("~/ajaxcore/wsdl.xslt"), XsltSettings.TrustedXslt, resolver);
Implementing a WCF service for Ajax
Implementing a WCF service for Ajax is almost as simple as programming an *.asmx based service but you can also use an external C# class or interface for implementing the service.
You can find a sample source code in:
By default the WCF services use the SOAP 1.2 format but we don’t need the ws-* functionality and the soap basic profile is perfect for using webservice with AJAX solutions. This can be done by using the following configuration in web.config:
<system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="AjaxBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="AjaxBehavior" name="CalcFactors"> <endpoint address="" binding="basicHttpBinding" contract="CalcFactors" /> </service> </services> </system.serviceModel>