0

NET 4.0 で WCF サービスを作成し、XML を返します。SoapUI を使用してテストしましたが、必要な応答 xml を確認できます。しかし、私の WCF サービスはサードパーティのソフトウェアによって呼び出され、asmx のような URL を介して使用したいと考えています。グーグルで調べたところ、REST ガイドラインを使用する必要があることがわかりました。ただし、RESTを使用してWebサービスを作成し、Webサービスと同様にブラウザからメソッドにアクセスすることを示す適切なリンクが見つかりませんでした。

以下は、XMLでフォーマットを返すために使用したインターフェースコードです

public interface IService1
{

    [WebGet(
        UriTemplate = "/GetDocument/",
        BodyStyle = WebMessageBodyStyle.Bare,
        ResponseFormat = WebMessageFormat.Xml)]

    [OperationContract, XmlSerializerFormat]
    XmlElement GetDocument();

    // TODO: Add your service operations here
}

以下は私の構成設定です。

<system.serviceModel>
<services>
  <service name="BritishLandXML.BritishLandXML1" behaviorConfiguration="metadataBehavior">
    <endpoint address="" binding="basicHttpBinding" contract="BritishLandXML.IService1" />        
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>

<bindings>
  <webHttpBinding>
    <binding>
      <security mode="None"></security>
    </binding>
  </webHttpBinding>
</bindings>

<behaviors>
  <endpointBehaviors>
    <behavior name="rest">
      <webHttp helpEnabled="true" faultExceptionEnabled="true" automaticFormatSelectionEnabled="true" />
    </behavior>
  </endpointBehaviors>

  <serviceBehaviors>
    <behavior name="metadataBehavior">
      <!-- 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="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

これを達成する方法と、正確な設定が必要になる方法を教えてください。

4

0 に答える 0