&引用;“404未找到”;在jQuery客户端和WCFSOAPWeb服务之间

&引用;“404未找到”;在jQuery客户端和WCFSOAPWeb服务之间,jquery,wcf,soap,Jquery,Wcf,Soap,有人能发现我的代码有什么问题吗?当我使用jQuery调用WCFSOAP服务时,在firebug上找不到404 我在Win7上使用IIS7。我将wcf作为()在虚拟目录应用程序上运行。我可以通过以下url访问service.svc文件,没有问题:() 这是我的Web.config,位于配置标记之间 <configuration> <system.web> <compilation debug="true" targetFramework="4.0"/>

有人能发现我的代码有什么问题吗?当我使用jQuery调用WCFSOAP服务时,在firebug上找不到404

我在Win7上使用IIS7。我将wcf作为()在虚拟目录应用程序上运行。我可以通过以下url访问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>
App_Code/CatalogServices.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);}
public class CatalogService : ICatalogService{
public string HelloWorld(string name){
    return String.Format("Hello {0}", name);}}
jQuery调用:

    $.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>
CarlosK

jQuery代码中的URL错误。尝试使用。还将内容类型更改为text/xml;字符集=utf-8

编辑:

地址:调用SOAP服务时,操作名称不是URL的一部分。(与休息服务相反)。在配置中,还定义了SOAP端点的相对地址。有效URL为BaseAddress+/service.svc+/RelativeAddress。基于的地址由虚拟目录定义

内容类型:您正在BasicHttpBinding上公开服务。BasicHttpBinding使用SOAP 1.1。SOAP1.1的正确内容类型是text/xml和charset

编辑新错误:


新错误表示无法将空操作路由到服务中的操作。您必须通过jQuery将SOAPAction HTTP头添加到您的请求构建中。jQuery代码中的标题值应为URL错误。尝试使用。还将内容类型更改为text/xml;字符集=utf-8

编辑:

地址:调用SOAP服务时,操作名称不是URL的一部分。(与休息服务相反)。在配置中,还定义了SOAP端点的相对地址。有效URL为BaseAddress+/service.svc+/RelativeAddress。基于的地址由虚拟目录定义

内容类型:您正在BasicHttpBinding上公开服务。BasicHttpBinding使用SOAP 1.1。SOAP1.1的正确内容类型是text/xml和charset

编辑新错误:


新错误表示无法将空操作路由到服务中的操作。您必须通过jQuery将SOAPAction HTTP头添加到您的请求构建中。标题的值应该是

非常好,我已经更改了jQuery代码中的URL和内容类型,并且我得到了一个不同的错误(带有操作“”的消息无法在接收者处处理…),我相信您的响应地址的“地址”和“内容类型”部分是错误的。你能给我一个有效URL(BaseAddress+/service.svc+/RelativeAddress)的例子吗。()这是一个很好的错误,因为这意味着您已经在呼叫服务,因此地址是正确的。等等。。。没有关系。我现在得到一个单独的问题错误,我会问另一个问题。非常感谢。我不知道如何在请求jQuery头()中指定它。有什么想法吗?我是jquerynoob。我可以帮助您使用SOAP和WCF,但对于jQuery,您需要其他人。很好,我更改了jQuery代码中的URL和内容类型,并得到了一个不同的错误(带有操作“”的消息无法在接收者处处理…),我相信您的响应地址的“地址”和“内容类型”部分。你能给我一个有效URL(BaseAddress+/service.svc+/RelativeAddress)的例子吗。()这是一个很好的错误,因为这意味着您已经在呼叫服务,因此地址是正确的。等等。。。没有关系。我现在得到一个单独的问题错误,我会问另一个问题。非常感谢。我不知道如何在请求jQuery头()中指定它。有什么想法吗?我是jquerynoob。我可以帮助您使用SOAP和WCF,但对于jQuery,您需要其他人。