1

これで十分です。に行くとsite/core.svc/dowork400エラーが発生します。

結果は.ajax呼び出しでも同じです。どこで私は間違えましたか?

このウェブにアクセスできるようにしようとしています。ブラウザのイベントに基づいて状態管理を処理するメソッドを追加します。

[ServiceContract]
public interface Icore
{
    [OperationContract]
    [WebGet(ResponseFormat = WebMessageFormat.Xml)]
    string DoWork();
}

[System.Web.Script.Services.ScriptService]
public class core : Icore
{
    public string DoWork()
    {
        return "hello";
    }
}

<behaviors>
  <endpointBehaviors>
    <behavior name="RestBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="MetadataBehavior">
      <serviceMetadata httpsGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<services>
  <!-- Note: the service name must match the configuration name for the service implementation. -->
  <service name="Fusion.core" behaviorConfiguration="MetadataBehavior" >
    <!-- Add the following endpoint.  -->
    <!-- Note: your service must have an http base address to add this endpoint. -->
    <endpoint contract="Fusion.Icore" binding="wsHttpBinding" bindingConfiguration="HttpsBinding" address="" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

<bindings>
  <basicHttpBinding>
    <binding name="secureBinding">
      <security mode="Transport"/>
    </binding>
  </basicHttpBinding>
  <wsHttpBinding>
    <binding name="HttpsBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
4

1 に答える 1

2

その場合、サービスをWebアクセス可能(通常のブラウザーから呼び出し可能)にする場合は、RESTアプローチ(SOAPではない)を使用する必要があります。

そのため、間違ったバインディングを使用しています。使用する必要がありますwebHttpBindingwsHttpBindingまたはbasicHttpBinding、ブラウザだけから呼び出すことのできないSOAPバインディングです。SOAPクライアントソフトウェアが必要です)

于 2012-12-21T19:04:05.513 に答える