在IIS 5.1中托管WCF Rest [英] Hosting WCF Rest in IIS 5.1

查看:62
本文介绍了在IIS 5.1中托管WCF Rest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个WCF插件,可以在我的开发机(Visual Studio Web服务器)上正常工作.但是我无法使其在QA服务器(带有IIS 5.1(已启用SSL)的Windows XP)中运行. (错误请求"或未找到")
如果我转到IIS并将映射.*"设置为"aspnet_isapi.dll",那么一切都会好起来的.但由于某些原因,我不想这样做(例如,我将丢失默认的文档行为!).

有什么好办法解决这个问题吗?

这是我的服务器代码:

Hi Guys,

I have a WCF rest which is working fine in my development machine (Visual Studio web server). But I can not make it work in my QA server which is windows XP with IIS 5.1 (SSL enabled). ("Bad Request" or "not found")
If I go to the IIS and set the mapping ".*" to "aspnet_isapi.dll", then everything will be fine. but for some reason I don''t want to do that (for example I will lose the default document behaviour!).

Is there any good way to solve this problem?

Here is my server code:

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode= AspNetCompatibilityRequirementsMode.Allowed)]
public class AjaxJSON : WCFBase

  [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate= "/Obj/Get/Status/{ObjID}")]                
  public AjaxJSONResponse_ObjIDStatus getImage(string ObjID)
  {
     // Do something and return 
  }
}



而且我的Global.asax中有此代码



and I have this code in my Global.asax

RouteTable.Routes.Add(new ServiceRoute("Rest",
     new WebServiceHostFactory(),
     typeof(Test.AjaxJSON)));





here is my config file ( application works in my development machine without this configuration using default configuration)

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <bindings>
        <basicHttpBinding>
            <binding name="AjaxJSONSBinding">
                <security mode="Transport">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="AjaxJSONServiceBehavior">
                <serviceMetadata httpsGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="AjaxJSONServiceBehavior" name="Test.AjaxJSON">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="AjaxJSONSBinding" contract="Test.AjaxJSON"/>
        </service>
    </services>
</system.serviceModel>



我也尝试过从Javascript(JQuery)调用.svc.但没有机会!

欢迎所有答复.

谢谢.



I have also tried calling the .svc from the Javascript (JQuery). but no chance!

all responses are welcome.

Thank you.

推荐答案

好的,我认为没有办法!
但是至少我发现了为什么我无法直接拨打.svc/...的原因. 对于可能有相同问题的其他豌豆:

我的服务位于asp.net站点内的文件夹(WCF)中,该文件夹是常规目录,而不是虚拟目录".所以我必须这样打电话给我的服务:
https://服务器/[virtualFolderName]/WCF/AjaxJSON.svc/Obj/Get/Status/[ObjId]
哪个没用!

我删除了AjaxJson.svc并将其直接放在根文件夹中,它解决了该问题!

现在的路径是:
https://server/[virtualfoldername]/AjaxJson.svc/Obj/Get/Status/[ObjId]
OK, I think there is no way to do that!
But at least I have found why I could not make a call directly to the .svc/...
for the other peaoples who may have the same problem:

I had my service in a folder (WCF) inside my asp.net site which is a normal directory and not a "virtual directory". So I had to call my service like this:
https://server/[virtualFolderName]/WCF/AjaxJSON.svc/Obj/Get/Status/[ObjId]
which did not work!

I remove the AjaxJson.svc and put it directly in the root folder and it solved the problem!

now the path is:
https://server/[virtualfoldername]/AjaxJson.svc/Obj/Get/Status/[ObjId]


这篇关于在IIS 5.1中托管WCF Rest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆