Can anyone spot what is wrong with my code? I'm getting a 404 Not Found on firebug when i use jQuery to call a WCF SOAP service.
I'm on Win7 using IIS7. I have the wcf running on a virtual directory application as (http://localhost/csw). I can access the service.svc file with no problem here at this url: (http://localhost/csw/service.svc)
Here is my Web.config between the configuration tags
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name ="soapBinding">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="CatalogService" behaviorConfiguration="defaultBehavior">
<endpoint address="soap"
binding="basicHttpBinding"
bindingConfiguration="soapBinding"
contract="ICatalogService" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="xmlBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="defaultBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
App_Code/ICatalogServices.cs:
[ServiceContract(Namespace = "http://test/CatalogService")] public interface ICatalogService {
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.Wrapped,
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml)]
string HelloWorld(string name);}
App_Code/CatalogServices.cs:
public class CatalogService : ICatalogService{
public string HelloWorld(string name){
return String.Format("Hello {0}", name);}}
jQuery call:
$.ajax({
type: 'POST',
url: 'http://localhost/csw/service.svc/HelloWorld',
data: request,
contentType: 'application/xml; charset=utf-8',
dataType: 'xml',
success: function (result) {
console.log(result);
$("#result").text(result);
//result.responseXML
//result.responseText
},
error: function (message) {
console.log(message);
alert("error has occured" + message);
}
});
my request xml is:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <HelloWorld xmlns="http://test/CatalogService"> <name>CarlosK</name> </HelloWorld> </s:Body> </s:Envelope>