Web サービスで POST と GET の両方を実行するのにイライラしています。私は立ち止まって、冷静になって、何がうまくいかないのかを理解する必要があります.
文字列を取得してエコーバックするだけの非常に単純な方法に分解しました。これは、自分のローカルホストに設定した IIS で動作し、運用ボックスで動作しますが、同じ構成がテスト システムで壊れています。私が間違っていることを教えてください。アクセス時:
http://test.softwaredesignexcellence.com/WebPostService/WebPostSvc.svc/json/Test?testtext=test%20me
「サービス」というテキストを含む太字のヘッダーと、「エンドポイントが見つかりません」という小さなテキストのサブヘッダーを持つページを取得しています。このメッセージが表示されるのはなぜですか? クエリ文字列「http://localhost/Services/WebPostSvc.svc/json/Test?testtext=test%20me」を使用して、同じサービスがローカル ホストで動作します。そして、私は応答を得ています:
<string>Echoing test me</string>
内部であるため、リンクを貼ることができない本番サーバーは、わずかに異なる応答を示していますが、それでも正常に動作しています。
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Echoing test me</string>
ローカルで公開し、ローカル Web サーバーにアクセスすると、すべてが機能していてイライラします。公開されたフォルダーを運用サーバーにコピーし、そのサーバーで同様の URL を入力すると、すべてが機能します。次に、同じコードと同じ設定をテスト サーバーに ftp すると、上記のエラー (エンドポイント見つかりません。)。 簡単なサービスをテスト サーバーで実行できない理由は何ですか?
Web サービスのインターフェース:
[ServiceContract( Namespace="http://services.alorica.com/WebPostSvc/1.0" )]
public interface IWebPostSvc
{
[OperationContract]
[WebGet]
string Test(string testtext);
}
これは私が働こうとしている簡単な方法です:
[WebService(Namespace = "http://services.alorica.com/WebPostSvc/1.0")]
[ServiceBehavior(Namespace = "http://services.alorica.com/WebPostSvc/1.0")]
public class WebPostSvc : IWebPostSvc
{
public string Test(string testtext)
{
return String.Format("Echoing {0}", testtext);
}
}
すべてを機能させようとして設定をいじっていたので、私の設定は扱いにくくなっています。更新 - serviceHostingEnvironment セクションを削除しましたが、必要ではないようでした。Web サービスはまだ稼働しており、SOAP で動作していますが、json はまだ「エンドポイントが見つかりません」と表示しています。
<system.serviceModel>
<!-- Set up Custom Behaviors -->
<behaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SvcMetaBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<!-- Set up the binding configuration -->
<bindings>
<basicHttpBinding>
<binding name="SOAPBinding">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="JSONBinding"
hostNameComparisonMode="StrongWildcard"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
openTimeout="00:10:00"
closeTimeout="00:10:00"
maxReceivedMessageSize="1000000"
maxBufferPoolSize="2000000"
bypassProxyOnLocal="false"
useDefaultWebProxy="true" >
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<!-- -->
<service behaviorConfiguration="SvcMetaBehavior"
name="WebPostService.WebPostSvc"
>
<endpoint address="soap"
binding="basicHttpBinding"
bindingConfiguration="SOAPBinding"
contract="WebPostService.IWebPostSvc"
/>
<endpoint address="json"
binding="webHttpBinding"
bindingConfiguration="JSONBinding"
behaviorConfiguration="jsonBehavior"
contract="WebPostService.IWebPostSvc"
/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
</system.serviceModel>