私は WCF を学んでおり、Visual Studio 2008 とその Web サーバーを使用して、私の開発環境で次のコードが動作しています。Web サービスを IIS 6 に発行すると、すべての要求で 400 "Bad Request" エラーが発生します。IIS ログを見ると、ステータス コードは 400 で、win32 ステータス コードは1380net helpmsg 1380
です。しかし、認証やセキュリティ メソッドを使用しない REST にはwebHTTPBindingを使用しています。
IIS では、「IUSER_<machine_name>」アカウントを偽装するように設定された匿名を許可するようにアプリケーションを設定しています。アプリケーション プールでは、Network Service ID を使用するように設定しています。両方のユーザーは、一時フォルダーと .net フレームワーク フォルダーにアクセスするように設定されています。WCF トレースをセットアップしましたが、ログが空白です。頭を壁にぶつけています。誰か助けてくれませんか?
web.config の System.ServiceModel 部分:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="default" name="GTKK.ServiceLibrary.GTKKService">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="" name="web" contract="GTKK.ServiceLibrary.IGTKKService" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="mex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1173/GTKKService" />
</baseAddresses>
</host>
</service>
</services>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
</system.serviceModel>
これが私のサービス契約です:
using GTKK.DTO;
using System.ServiceModel.Web;
namespace GTKK.ServiceLibrary
{
[ServiceContract(SessionMode=SessionMode.Allowed)]
public interface IGTKKService
{
[WebGet(UriTemplate = "artist/{id}/json", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
ArtistDTO GetArtistByID(string id);
[WebGet(UriTemplate = "artists/json?namefilter={namefilter}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
List<ArtistDTO> GetArtistListByNameFilter(string nameFilter);
[WebGet(UriTemplate = "localevents/json?search={searchText}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
List<EventDTO> GetLocalEventsBySearchLocationJson(string searchText);
[WebGet(UriTemplate = "localevents/xml?search={searchText}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml)]
[OperationContract]
List<EventDTO> GetLocalEventsBySearchLocationXml(string searchText);
}
}
ブラウザーでは、VS2008 Web サーバーを使用して開発環境でテストするために次の URL を使用し、動作します。
http://localhost:1173/GTKKService/localevents/xml?search=98101
IIS に公開して次の URL を使用すると、不正な要求ページが表示されます。
http://<host_name>/service.svc/localevents/xml?search=98101
.svc 部分の後に誤った URL を入力したかのように、URL が正しいはずであることはわかっています。エンドポイントが見つからないというエラーが表示されますが、これは正常に機能しています。例えば:
http://<host_name>/service.svc/anythinghere
IIS サーバー ボックスには、.net 2、3.0、および 3.5 がインストールされています。IIS Web アプリケーションは、.net 2 (.net 3.5 を使用) を使用するようにセットアップされています。また、serviceModelReg /i /x と /ia を実行して、WCF がインストールされ、登録されていることを確認しました。「Bad Request」エラー ページについては、IIS エラー ページではなく、WCF エラー ページのような HTML 形式であり、上部に紺色のバーがあり、白いタイトル「Request Error」とそれに続くメッセージ「Theサーバーでリクエストの処理中にエラーが発生しました。詳細については、サーバー ログを参照してください。 "
助けてください。