Web サービスを作成し、WCF 4
それを でホストしました。プロジェクトの発行 Web セクションでIIS 7
次のように指定しました。Service URL:
WCF
http://localhost:8084/service1.svc
.
web site
次に、公開されたポート:4567
とタイプ:をバインドhttp
しIIS
ます。
To checked it i clicked on `web site` at `IIS` and click on the browse.
It open a following page at my browser:
これは、Web サービスが で正常にホストされていることを意味しIIS
ます。ここで、インスタンス メソッドを呼び出して、ブラウザで出力を返したいと思います。Iservice.cs
とのサンプルコードを貼り付けさせてくださいservice.svc.cs
#Iservice.cs:
namespace some.decryption
{
[ServiceContract]
public interface Iservice
{
[OperationContract, WebInvoke(Method = "GET", UriTemplate = "/getdata", ResponseFormat = WebMessageFormat.Json)]
string getdata();
}}
一方、私のservice.svc.cs
:
public bool getdata()
{
return somenamespace.getfetcheddll();
}
とserviceDll.cs
:
namespace somenamespace{
internal static class UnsafeNativeMethods
{
_dllLocation = "some.dll";
[DllImport(_dllLocation, CallingConvention = CallingConvention.Cdecl)]
public static extern bool OnDecryption();
}
public static string getfetcheddll()
{
return UnsafeNativeMethods.OnDecryption();
}}
getdata()
ブラウザからメソッドを呼び出すにはどうすればよいですか?
私はsome.dll
同じプロジェクトフォルダに入れました。どこにすればいいですか?
編集:
を貼り付けるのを忘れましたweb.config
:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
これを行うために、私はこのブログに従いました:作成に関するウォークスルー