C# WCF Rest服务未调用

C# WCF Rest服务未调用,c#,.net,wcf,wcf-rest,restful-url,C#,.net,Wcf,Wcf Rest,Restful Url,我无法呼叫Rest服务。但我能够调用WSDL文件。下面是我的WEB.CONFIG <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> &l

我无法呼叫Rest服务。但我能够调用WSDL文件。下面是我的WEB.CONFIG

    <?xml version="1.0"?>
<configuration>

    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.serviceModel>
        <services>
            <service name ="APWPortalWCFServices.APWPortalWCFService" >
                <endpoint name="RestAPWPortal"
                          address="APWPortalRestful"
                          binding="webHttpBinding"  behaviorConfiguration="APWPortalBehavConfig"
                          contract="APWPortalWCFServices.IAPWPortalContract" >    
                <identity>
                    <dns value="localhost"/>
                </identity>                    
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
        <behaviors>
            <endpointBehaviors>
                <behavior name="APWPortalBehavConfig">
                    <webHttp helpEnabled="True"/>
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior>
                    <!-- 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>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
</configuration>
服务实施:

namespace APWPortalWCFServices
{
    [ServiceContract]
    public interface IAPWPortalContract
    {
        [OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetMyData")]
        Stream GetData();
    }
}
namespace APWPortalWCFServices
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class Service1 : IAPWPortalContract
    {
        public Stream GetData()
        {
            MemoryStream msSubMenuImages = null;
            StringBuilder sbRes = new StringBuilder();

            SqlConnection sqlcon = new SqlConnection("server=192.168.1.2;uid=sa;pwd=xenoDev+eam;database=CinemarkMigration;");
            sqlcon.Open();
            DataSet ds = null;
            SqlDataAdapter sqlda = new SqlDataAdapter("SELECT TOP 10000 * FROM tblHeaderFieldValue", sqlcon);
            sqlda.Fill(ds);

            sbRes.Append(ConvertDatatableToJSON(ds.Tables[0]));

            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
            msSubMenuImages = new MemoryStream(Encoding.UTF8.GetBytes(sbRes.ToString()));
            return msSubMenuImages;
        }
        public string ConvertDatatableToJSON(DataTable dtData)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = null;
            List<Dictionary<string, object>> rows = null;
            try
            {
                serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                rows = new List<Dictionary<string, object>>();
                Dictionary<string, object> row = null;

                foreach (DataRow dr in dtData.Rows)
                {
                    row = new Dictionary<string, object>();
                    foreach (DataColumn col in dtData.Columns)
                    {
                        if ((col.DataType == typeof(DateTime)) && dr[col] != null && dr[col].ToString().Trim() != string.Empty)
                            row.Add(col.ColumnName, DateTime.Parse(dr[col].ToString()).ToString("MM/dd/yyyy"));
                        else if ((col.DataType == typeof(Decimal)) && dr[col] != null && dr[col].ToString().Trim() != string.Empty)
                            row.Add(col.ColumnName, Decimal.Parse(dr[col].ToString()).ToString("0.00"));
                        else
                            row.Add(col.ColumnName, dr[col]);
                    }
                    rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return serializer.Serialize(rows);
        }

    }
}

这是给作为空白页。我已经把调试点也。如果url不是我正在进行自托管,请在此帮助我。那么我们如何在localhost中检查它呢?尝试从
GetData
方法返回
Stream
以外的内容<代码>流希望您开始流式传输数据。。。。。尝试返回
字符串
int
以查看是否有效。即使我将返回类型更改为int/string也不起作用如果您是自宿主,则不需要
.svc
扩展名。试试
http://localhost:50232/APWPortalRestful/GetMyData
我看不到任何地方配置了基地址。
[http://localhost:50232/APWPortalWCFService.svc/APWPortalRestful/GetMyData]