I created a WCF 4
web services and hosted it on my IIS 7
, I gave the following Service URL:
at publish web section in WCF
project:
http://localhost:8084/service1.svc
.
Then i bind my published web site
on port:4567
and Type: http
in IIS
.
To checked it i clicked on `web site` at `IIS` and click on the browse.
It open a following page at my browser:
It means that the web service is successfully hosted on IIS
. Now i want to call my instances method and return the output at browser. Let me paste you the sample code of Iservice.cs
and service.svc.cs
#Iservice.cs:
namespace some.decryption
{
[ServiceContract]
public interface Iservice
{
[OperationContract, WebInvoke(Method = "GET", UriTemplate = "/getdata", ResponseFormat = WebMessageFormat.Json)]
string getdata();
}}
Whereas my service.svc.cs
:
public bool getdata()
{
return somenamespace.getfetcheddll();
}
and 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();
}}
how should i call getdata()
method from browsers?
I have put the some.dll
in the same project folder. Where should i do it?
I have forgot to paste my 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" />
To do this i followed this blog : walkthrough on creating
By default - HTTP
is translated into wsHttpBinding
which is a SOAP service, so you cannot just call that from a browser. The ?wsdl
suffix on the help page also seems to point in that direction.
For testing SOAP services, you need a SOAP-capable tool like the Microsoft WCF Test Client or SoapUI.
Try using the WCF Test Client - can you connect to your service at the URL shown on the help page with that tool? Do you see your service?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With