Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call my WCF service from browser?

I'm writing a webservice that is suppose to save json two json strings to DB. I can invoke it with sope UI and WCF Test Client but I can't call it from my browser. Is there some way to do that?

The service will initially be used by android app and I have tried calling from it with out any luck.

Here is the interface of my service:

 [ServiceContract]
public interface IRService
{
    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Wrapped,
       UriTemplate = "SaveCallResults?callInfo={callInfo}&testInfo={testInfo}")]
    string SaveCallResults(string callInfo, string testInfo);
}

And here is my web.config

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_RService" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      allowCookies="false" bypassProxyOnLocal="false"            hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="524288" maxBufferSize="65536" maxReceivedMessageSize="65536"
      textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
      messageEncoding="Text">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"
  multipleSiteBindingsEnabled="true" />
<services>
  <!-- causing error -->
  <!--<service name="NovaRoadRunnerWS.RService" behaviorConfiguration="ServiceBehaviour" >
    <endpoint address="" binding="webHttpBinding" contract="NovaRoadRunnerWS.IRService" behaviorConfiguration="web" >
    </endpoint>
  </service>-->
</services>

like image 295
Gumbo Avatar asked Apr 07 '13 16:04

Gumbo


People also ask

How can I access WCF service?

With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.

Can we call WCF service from Java?

For Java client application, I think you can generate the proxy class from Eclipse and invoke the call to WCF service. The general steps are as follows: Prepare the WCF service and run the service. Create the Java client application in Eclipse IDE, and name the project, like WCFClientApp in this case.

How do I access SVC files?

Solution: Open IIS Manager (Start > Run > search "inetmgr"). Browse from the top level server to Sites and expand the Default Web Site. Select each of the Revit Server applications, and in the Content View, right click on the SVC file and select Browse.


1 Answers

There are several errors in the web.config:

  1. There is no service behavior named ServiceBehaviour behaviorConfiguration="ServiceBehaviour"

  2. There is no endpoint behavior named web: behaviorConfiguration="web"

  3. No name was given to the serviceBehaviors section: <behavior name="">

I made the following change to fix the error:

<behaviors>
  <serviceBehaviors>
    <behavior name="web">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

and

<services>
  <service name="NovaRoadRunnerWS.RService" behaviorConfiguration="web" >
    <endpoint address="" binding="webHttpBinding" contract="NovaRoadRunnerWS.IRService"  >
    </endpoint>
  </service>
</services>
like image 89
Syed Raihan Avatar answered Oct 03 '22 16:10

Syed Raihan