2011-01-16 17 views
1

私はWCFを新しくしていますので、私にご負担ください。WCFスターターキットを使用してSOAPエンドポイントを公開するにはどうすればよいですか?

最新バージョンのWCF RESTスターターキットを使用して、Androidアプリケーションから呼び出されているWebサービスを作成しました。 RESTfulエンドポイントは正常に動作していますが、.NETクライアントがそれを使用して必要なクラスをすべて生成できるようにSOAPエンドポイントを作成したいと考えています。

私はまだデフォルト設定ファイルを使用していますが、私は何をする必要があるのか​​少し混乱しています。

ここでは、私は、configファイルの中にどこかに以下を追加する必要がありますが、私は正しい道の上だ場合、それが属しているか、どこがわからないと思う

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

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 

    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    </modules> 
    </system.webServer> 

    <system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
    <standardEndpoints> 
     <webHttpEndpoint> 
     <!-- 
      Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
      via the attributes on the <standardEndpoint> element below 
     --> 
     <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/> 
     </webHttpEndpoint> 
    </standardEndpoints> 
    </system.serviceModel> 

</configuration> 

です。

<endpoint name="mex" address="mex" binding="mexHttpBinding" contract="Service1"/> 
<endpoint name="soap" address="soap" binding="basicHttpBinding" contract="Service1"/> 

私はクラスが1つしかなく、それはService1.csです。私はいくつかの変更を加えようとしましたが、私は成功しませんでした。

私は何を追加しなければならないのか、それがなぜ必要なのかを説明したいと思います。

- 更新 - 私は、サービスタグを挿入した後

、私は、Visual Studioで作業する機能「サービス参照の追加」を取得してトラブルを抱えていました。私は 'HttpGetEnabled'が真である必要があることを知ったので、サービスメタデータをhttpに公開します。

これを追加して、動作しているようです。

<behaviors> 
      <serviceBehaviors> 
       <behavior name="Service1Behavior"> 
        <serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 

さらにサービスを追加すると、そのサービス用にさらに2つのエンドポイントを作成する必要がありますか?

ありがとうございました。

答えて

0

あなたはあなたのサービスに追加のエンドポイントを公開する場合は、あなたの設定に<service name="....">タグにそれらを追加する必要があります。

<system.serviceModel> 
    <services> 
    <service name="NameSpace.ServiceClassName> 
     <endpoint name="rest" 
       address="" 
       binding="webHttpBinding" 
       contract="IService1" /> 
     <endpoint name="soap" 
       address="soap" 
       binding="basicHttpBinding" 
       contract="IService1" /> 
     <endpoint name="mex" 
       address="mex" 
       binding="mexHttpBinding" 
       contract="IMetadataExchange" /> 
    </service> 
    </services> 
</system.serviceModel> 

あなたは明らかに露出しているWCF 4の標準的なエンドポイントを使用している - あなたの場合それを変更したい場合は、必要なすべての設定を明示的に綴る必要があります。あなた* .SVCファイルのベースアドレスがwebHttpBinding

  • (service.svc)/soapを使用してRESTエンドポイントになります

    • 今、あなたのサービスは、(NameSpace名前空間にServiceClassNameで実装されている)3つのエンドポイントを持っていますアドレスは同じ契約(同じサービス方法)になりますが、SOAPベースのbasicHttpBinding

    • のアドレスを使用すると、(service.svc)/mexアドレスはSOAPクライアントのサービスメタデータを持ちます
  • 関連する問題