2016-07-18 1 views
1

でWCFサービスのエンドポイントを追加することはできません:これは、WCFサービスの私<code>Web.config</code>あるWinFormsの

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="Mobile55.Service1"> 
     <endpoint address="../Service1.svc" 
      binding="webHttpBinding" 
      contract="Mobile55.IService1" 
      behaviorConfiguration="webBehaviour" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="webBehaviour"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <httpProtocol> 
    <customHeaders> 
     <add name="Access-Control-Allow-Origin" value="*" /> 
     <add name="Access-Control-Allow-Headers" value="Content-Type, Accept" /> 
    </customHeaders> 
    </httpProtocol> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 

</configuration> 

は、これは私がWCFで働いています初めてのことであると私は私のWinFormsアプリケーションでこのサービスのエンドポイントを追加することはできません。

は、私が参照として本サービスを追加したと私はメソッドにアクセスすることができますが、私のデバッグはそれが例外をスローするメソッドを呼び出ししようとする場合:

Could not find default endpoint element that references contract 'MyService.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

私のアプリケーションapp.configファイルは空です。

私は、次の答えを試みたが、私のために動作しませんでした:

Could not find default endpoint element

Could not find default endpoint element that references contract - Hosting wcf

WCF Error - Could not find default endpoint element that references contract 'UserService.UserService'

私はようやく私を使用できるようにエンドポイントを追加するにはどうすればよいですサービス?

ありがとうございます。

EDIT:マイapp.configファイル:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
<system.serviceModel> 
<services> 
    <service name="Mobile55.Service1"> 
    <endpoint address="" 
     binding="webHttpBinding" 
     contract="Mobile55.IService1" 
     behaviorConfiguration="webBehaviour" /> 
    </service> 
</services> 

<behaviors> 
    <serviceBehaviors> 
    <behavior name="webBehaviour"> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

<client> 
    <endpoint address="http://localhost:1008/Service1.svc" 
    binding="webHttpBinding" 
    contract="Mobile55.IService1" 
    behaviorConfiguration="webBehaviour" /> 
</client> 
</system.serviceModel> 
</configuration> 

答えて

0

エラーメッセージは具体的にはclient configuration sectionと表示されています。 エラーはクライアント側で発生します。つまり、サービス上で呼び出しようとするコードから発生します。適切な例外/スタックトレースと、その動作を示す完全なコンパイル可能な例がないと、それ以上のことを伝えられません。

とにかく、設定ファイルにclientセクションが完全にありません。まだ同じエラーを与えて

<system.serviceModel> 
    <!-- ... other stuff you have ... --> 
    <client> 
     <endpoint address="../Service1.svc" 
      binding="webHttpBinding" 
      contract="Mobile55.IService1" 
      behaviorConfiguration="webBehaviour" /> 
    </client> 
</system.serviceModel> 
+0

ありがとうございます。 'webBehaviour'という名前のエンドポイントの動作はありません。 –

+0

' system.serviceModel'セクションに 'client'要素を本当に追加しましたか、またはセクション全体を何に置き換えましたか?私が書いた? –

+0

上記のapp.configコンテンツを追加しました。あなたは見てみることができますか? –

0

このような何かがうまくいけば

<service name="MyService.Service1"> 
    <endpoint address="YourEndPointHere" 
     binding="webHttpBinding" 
     contract="MyService.IService1" 
     behaviorConfiguration="webBehaviour" /> 
    </service> 
0

あなたがあなたを呼び出すことができます。この

<service name="Mobile55.Service1"> 
     <endpoint address="" 
      binding="webHttpBinding" 
      contract="Mobile55.IService1" 
      behaviorConfiguration="webBehaviour" /> 
     </service> 

で試すことができますトリックを行う必要がありますこのようなサービスは、

localhost:port/Service1.svc/Pathname 

ここで、パス名は、あなたがuritemplateのoperationcontractで述べたものです。

希望すると助かります!

+0

はこのような何かを追加します。 –

0
<system.serviceModel> 
<client> 
<endpoint address="http://localhost:1008/Service1.svc" 
binding="webHttpBinding" 
bindingConfiguration="webHttpBinding_IService" 
contract="Mobile55.IService1" 
name="webHttpBinding_IService" /> 
</client> 
</system.serviceModel> 


---------- 
## Heading ## 


Try.... 
+0

'web.config'または' app.config'では? –

+0

web.config ..... – abaravindan

関連する問題