0

I have created a wcf service and tested in local machine via WCFClient and its working fine then hosted in IIS while testing on iis machine, and following error comes out.

Service directory and service1.svc page is returning fine.

Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.

Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings />
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="restLargeBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
<readerQuotas maxStringContentLength="2147483647"/>
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name ="myWebEndPointBehaviour">
          <webHttp automaticFormatSelectionEnabled="true" defaultBodyStyle="Bare" defaultOutgoingResponseFormat="Json" helpEnabled="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="mybehaviour">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="MAT_Service.Service1" behaviorConfiguration="mybehaviour">
        <host>
          <baseAddresses>
            <add baseAddress="https://125.209.80.46/Service1.svc" />
          </baseAddresses>
        </host>
        <endpoint address="" contract="MAT_Service.IService1" binding ="webHttpBinding" bindingConfiguration="restLargeBinding" behaviorConfiguration="myWebEndPointBehaviour"/>
        <endpoint address="mex" contract="MAT_Service.IService1" binding="mexHttpBinding" />
      </service>
    </services>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
      <add binding="basicHttpBinding" scheme="http" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="true" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
</configuration>

please help me outenter image description here

Faraz Naeem
  • 41
  • 1
  • 1
  • 7

1 Answers1

0

I found several problems with your code:
1.The metadata exchange (mex) endpoint should be:

 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 

2.You are using https protocol, so you need to set httpsGetEnabled to true.

  <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 

3.You are using webHttpBinding, but <protocolMapping> is using basicHttpBinding.
4.HTTPS is transport authentication, so you need to set:

<security mode="Transport">

5.Make sure your service is running.
I suggest you study the link below.
How to: Publish Metadata for a Service Using a Configuration File
How to make WCF Service Use HTTPS protocol
Host in Internet Information Services

Lan Huang
  • 613
  • 2
  • 5
  • will make you update after trying. thanks Lan – Faraz Naeem Jun 17 '22 at 07:22
  • One more thing i want to know one of my method in this service have a string parameter to pass, how to pass a parameter in fiddler , correct me if i am doing wrong. https://10.0.10.3/Service1.svc/GetSpecific?CardNum=001 – Faraz Naeem Jun 17 '22 at 07:25
  • The URL you provided doesn't show anything,But I think you can refer to [this thread](https://stackoverflow.com/questions/40587580/how-to-call-simple-wcf-from-fiddler). – Lan Huang Jun 17 '22 at 09:37