この例に従って、最初のWCFサービスであるWCF RESTサービスJSONを作成し、それを編集して独自のサービスを作成しました。ASP.NET Developer Serverを使用したデバッグで、サービスを正常に実行することができました。ポート8081(サーバー、ファイアウォール、ルーター上)を開き、IISの[登録]フォルダーに割り当てました。次に、MsDeployAgentServiceを使用する必要があることを理解した後、IIS6を実行しているWindowsServer2003にサービスを公開しました。次に、IISを使用してASP.NETのバージョンを4.0.3019に設定しました。Registrationフォルダーには、Service1.svc、Web.config、およびbinフォルダーが含まれています。
これは私のWeb設定ファイルです:
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="ServiceApp.Properties.Settings.RegistrationConnection"
connectionString="Data Source=EDITED;Initial Catalog=Registration;Persist Security Info=True;User ID=EDITED;Password=EDITED;MultipleActiveResultSets=True" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="524288" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="StreamedRequestWebBinding"
bypassProxyOnLocal="true"
useDefaultWebProxy="false"
hostNameComparisonMode="WeakWildcard"
sendTimeout="10:15:00"
openTimeout="10:15:00"
receiveTimeout="10:15:00"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
transferMode="StreamedRequest">
<readerQuotas maxArrayLength="2147483647"
maxStringContentLength="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="ServiceApp.Service1" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="StreamedRequestWebBinding" contract="ServiceApp.IService1" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
テストクライアントでサービスを利用しようとすると、次のステートメントでエラー404が発生します
byte[] data = client.DownloadData("http://ServerIP:8081/Registration/Service1.svc/CheckSoftware/1/Customer1/1_0/abc123/1/1");
ポートを削除すると、エラー401「許可されていません」が表示されます
byte[] data = client.DownloadData("http://ServerIP/Registration/Service1.svc/CheckSoftware/1/Customer1/1_0/abc123/1/1");
LANIPとWANIPアドレスを使ってみました。
OPが同じ例に従い、同様の問題が発生したように見えるため、この投稿をフォローしましたが、役に立ちませんでした。
次に、サーバーのイベントビューアを調べて、ポート番号に含めたときにこれを見つけました。
WebHost failed to process a request.
Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/23878916
Exception: System.Web.HttpException (0x80004005): The service '/Registration/Service1.svc' does not exist. ---> System.ServiceModel.EndpointNotFoundException: The service '/Registration/Service1.svc' does not exist.
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)
Process Name: w3wp
Process ID: 3460
Service1.svcファイルがフォルダーに存在することがはっきりとわかります。私はこの時点でかなり迷っています。助けていただければ幸いです。
より多くのコードを含めるように編集:
namespace ServiceApp
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "GET",
UriTemplate = "/CheckSoftware/{SoftwareId}/{CustomerId}/{Version}/{Key}/{MoboID}/{ProcessorID}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
SoftwareStatus CheckSoftware(string SoftwareID, string Version, string CustomerID, string Key, string moboID, string processorID);
[OperationContract]
[WebInvoke(
Method = "GET",
UriTemplate = "/SaveKey/{SoftwareId}/{CustomerId}/{Key}/{MoboID}/{ProcessorID}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
string SaveKey(string SoftwareID, string CustomerID, string Key, string moboID, string processorID);
}
[DataContract]
public class FileInformation
{
[DataMember]
public string Name
{
get;
set;
}
[DataMember]
public byte[] Content
{
get;
set;
}
}
[DataContract]
public class Employee
{
[DataMember]
public int Id
{
get;
set;
}
[DataMember]
public string Name
{
get;
set;
}
}
[DataContract]
public class SoftwareKey
{
[DataMember]
public string SoftwareId
{
get;
set;
}
[DataMember]
public string CustomerId
{
get;
set;
}
[DataMember]
public string Version
{
get;
set;
}
[DataMember]
public string Key
{
get;
set;
}
}
[DataContract]
public class SoftwareStatus
{
[DataMember]
public Boolean SoftwareId
{
get;
set;
}
[DataMember]
public Boolean CustomerId
{
get;
set;
}
[DataMember]
public Boolean Version
{
get;
set;
}
[DataMember]
public Boolean Key
{
get;
set;
}
[DataMember]
public Boolean HardwareID
{
get;
set;
}
}
}