有人能发现我的代码有什么问题吗?当我使用jQuery调用wcfsoap服务时,在firebug上找不到404。
我在用IIS7玩Win7。我在虚拟目录应用程序上运行wcf(
http://localhost/csw
). 我可以访问服务.svc此url中没有问题的文件:(
http://localhost/csw/service.svc
这是我的Web.config文件在配置标签之间
<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>
应用程序代码/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);}
应用程序代码/目录服务.cs:
public class CatalogService : ICatalogService{
public string HelloWorld(string name){
return String.Format("Hello {0}", name);}}
$.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);
}
});
<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>