0

I'm trying to pass object parameter as JSON format to WCF restful service.

service contract code like this;

 [OperationContract]
 [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "xml/{id}")]
 string XMLData(string ID);

And my web.config file like this;

<system.serviceModel>
<services>
  <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
    <endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" 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>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

When I trying call the service with "http://localhost/serviceurl/xml/123" url, Service returned "Method not allowed" error message.

klashar
  • 2,519
  • 2
  • 28
  • 38

1 Answers1

0

I resolved it. I had to remove the <ProtocolMapping> and <ServiceHostingEnvironment> tag from the web.config file.

Its works fine now.

DIF
  • 2,470
  • 6
  • 35
  • 49