2017-02-16 25 views
1

挨拶、現在私はブラウザでxml形式のサービスを表示するように取り組んでいます。Webサービスの機能が機能しないのはなぜですか?

しかし、それは空のページを示しています、なぜそこに説明がありますか?ファイアウォールの問題? すべてのファイルは以下のとおりです。

IProductService1.cs

using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using System.Text; 


namespace WCFRESTfulService 
{ 
// NOTE: You can use the "Rename" command on the "Refactor" menu to change  the interface name "IService1" in both code and config file together. 
[ServiceContract] 
public interface IProductService1 
{ 
    [OperationContract] 
    [WebGet] 
    List<product> GetAllProducts(); 

    [OperationContract] 
    [WebGet] 
    product GetProducts(string id); 

} 

} 

ProductService1.svc.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.Text; 

namespace WCFRESTfulService 
{ 
// NOTE: You can use the "Rename" command on the "Refactor" menu to change  the class name "Service1" in code, svc and config file together. 
// NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging. 
public class Service1 : IProductService1 
{ 

    public List<product> GetAllProducts() 
    { 
     using(var db=new estocktakeEntities()) 
     { 
      return db.products.ToList(); 
     } 
    } 


    public product GetProducts(string id) 
    { 
     Int32 _id = Convert.ToInt32(id); 
     using(var db=new estocktakeEntities()) 
     { 
      return db.products.SingleOrDefault(p => p.invtid == id); 


     } 


    } 
} 
} 

のWeb.config

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit  http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework"  type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,  EntityFramework, Version=6.0.0.0, Culture=neutral,  PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 

    <system.serviceModel> 
    <services> 
     <service name="myService.ProductService"> 
     <endpoint address="" behaviorConfiguration=""  binding="webHttpBinding" contract="MyService.IProductService"></endpoint>   
     </service> 
    </services> 
    <behaviors> 
    <endpointBehaviors> 
    <behavior name="restbehaviour"> 
     <webHttp/> 
    </behavior> 
    </endpointBehaviors> 
    <serviceBehaviors> 
    <behavior> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<protocolMapping> 
    <add scheme="https" binding="basicHttpBinding"/> 
</protocolMapping> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"></serviceHostingEnvironment> 
    </system.serviceModel> 



    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true" /> 
    </system.webServer> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <connectionStrings> 
    <add name="Model1" connectionString="data source=CHRISPHAN-HP\SQLEXPRESS;initial catalog=estocktake;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /><add name="estocktakeEntities" connectionString="metadata=res://*/productmodel.csdl|res://*/productmodel.ssdl|res://*/productmodel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=CHRISPHAN-HP\SQLEXPRESS;initial catalog=estocktake;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings> 
</configuration> 

私はWCFのテストツールを使用してそれをテストし、機能が働いています。任意の提案は、この長い記事のために申し訳ありませんが大きな助けになりますURL Get all product is not displaying

に機能を追加した後、ウェブサイト The service page which is working

でテスト

-UPDATE- YouTubeビデオでは、ブラウザでサービスを実行できません。 ウェブ ため VS2013を使用してSQL IIS Expressの

+0

あなたは、DBのデータを持っていますか? – Sajeetharan

+0

@Sajeetharanはい、私のデータベースにはレコードがあり、テストクライアントで作業しています。 – Chris

+0

@Chrisブラウザコンソールには何がありますか? – Mairaj

答えて

0

一般的にあなたがWCF

次のリンクを助けるべきでのRESTfulサービスを作成する必要がある必要がある、ブラウザからのWCFのメソッドを呼び出すには、XMLの結果が表示されないブラウザ、

Run WCF methods from a browser

関連する問題