0

私はWCFの世界が初めてです。私は、Web App(ソリューションの別のプロジェクトであるWCFサービスアプリケーションへのJQuery Ajax呼び出しを含む)を含むソリューションを持っています.2日間の作業(クラッキング)の後、私はリクエストを渡して応答を得ることができる状態にありますここに画像の説明を入力

しかし、アラートでそれを表示しようとすると、200パーサーエラーが発生します。ここに画像の説明を入力

どんな助けでも大歓迎です

さらなる参照

$.ajax({
                    async: true,
                    type: 'GET', //GET or POST or PUT or DELETE verb
                    url: 'http://localhost:61057/Service1.svc/GetCustomer', // Location of the service
                    dataType: 'jsonp', //Expected data format from server
                    success: function (data) {//On Successfull service call
                        ServiceSucceeded(data);
                    },
                    error: function () { ServiceFailed(Data); } // When Service call fails
                });

Web.config

  <system.serviceModel>
    <services>
      <service name="FIN.Services.Service1" behaviorConfiguration="DefaultBehavior">
        <endpoint address="http://localhost:61057/service1.svc" binding="webHttpBinding" contract="FIN.Services.IService1" behaviorConfiguration="AjaxBehavior">
          <identity>
            <dns value="locahost"/>
          </identity>
        </endpoint>
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding name="webBinding">
          <security mode="None">
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="AjaxBehavior">
          <enableWebScript/>
        </behavior>

      </endpointBehaviors>

    </behaviors>
  </system.serviceModel>

サービス インターフェイス:

[WebInvoke(ResponseFormat = WebMessageFormat.Json, Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json)]
        [OperationContract]
        string GetCustomer();
4

2 に答える 2

0

引数が必要ない場合は、ajax呼び出しに次を追加します。

データ: "{}"、

于 2012-06-05T18:45:55.967 に答える
0

jsonpを使用して います。これは、クロス ドメイン サービスを呼び出すことを意味します。クロス ドメイン サービスの場合、URL は次のようになります。

http://localhost:61057/Service1.svc/GetCustomer?callback=?

また、web.configにいくつかの変更を加える必要があります

完全な例については、次のリンクを参照してください

wcf でのクロス ドメイン サービスの呼び出し

于 2012-06-05T18:52:12.730 に答える