WCF Return Endpoint not found live

I have a WCF service in a shared environment that contains two different methods. One returns the desired result, and the other eliminates the exception of the endpoint, which is my main method of user authentication.

The script is shown here:

My Iservice.cs as below

[OperationContract]
[WebInvoke(Method="GET", UriTemplate = "Data?Id={id}", ResponseFormat=WebMessageFormat.Json)]
string GetData(string id);

[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "Login?InstId={inst}&UserId={user}&pwd={pwd}", ResponseFormat = WebMessageFormat.Json)]
string Authenticate(string inst, string user, string pwd);

which then authenticates the user data through the DAL, which works fine. My web configuration is as follows:

  <system.serviceModel>
    <!--<serviceHostingEnvironment multipleSiteBindingsEnabled="True" aspNetCompatibilityEnabled="True">
    </serviceHostingEnvironment>-->
    <serviceHostingEnvironment multipleSiteBindingsEnabled="True">
    </serviceHostingEnvironment>
    <services>
      <service name="WCFDemo.Service1">
        <endpoint address="http://www.ekotri.com/Service1.svc" behaviorConfiguration="restfulBehavior"
                  binding="webHttpBinding" listenUri="/" bindingConfiguration="" contract="WCFDemo.IService1">
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://www.ekotri.com" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="restfulBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="restfulBehavior">
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

GetData is working fine, but Authenticate gives the endpoint an undetected error. However, it works fine on local IIS.

+4
source share
3 answers

Try this configuration:

<system.serviceModel>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="True" aspNetCompatibilityEnabled="True">
</serviceHostingEnvironment>-->
<serviceHostingEnvironment multipleSiteBindingsEnabled="True">
</serviceHostingEnvironment>
<services>
  <service name="WCFDemo.Service1">
    <endpoint address="rest" behaviorConfiguration="restfulBehavior"
              binding="webHttpBinding" contract="WCFDemo.IService1">
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://www.ekotri.com/Service1.svc" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="restfulBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="restfulBehavior">
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

WCF .

+1

[OperationContract]
 [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "Login/{inst}/{user}/{pwd}",
    BodyStyle = WebMessageBodyStyle.Bare)]
string Authenticate(string inst, string user, string pwd);

,

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="customBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
      <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>
<services>
  <service behaviorConfiguration="asmx" name="WCFDemo.Service1">
    <endpoint address="basic" binding="basicHttpBinding" name="httpEndPoint" contract="WCFDemo.IService1"/>
    <endpoint address="json" binding="webHttpBinding" behaviorConfiguration="webBehavior" name="webEndPoint" contract="WebApplication1.IService"/>
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
  </service>
</services>
<behaviors>
    <endpointBehaviors>
        <behavior name="webBehavior">
            <webHttp />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
    <behavior name="asmx">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
+1

URL- , ?

According to your utility file, the URL pattern you are using is

Login?InstId={inst}&UserId={user}&pwd={pwd}

Next, in your configuration file, you bind it to a specific path to the domain / URL

<endpoint address="http://www.ekotri.com/Service1.svc" behaviorConfiguration="restfulBehavior"
                  binding="webHttpBinding" listenUri="/" bindingConfiguration="" contract="WCFDemo.IService1">

Based on these two pieces of information, the expected access path will be

http://www.ekotri.com/Service1.svc/Login?InstId={inst}&UserId={user}&pwd={pwd}

If I take this template and connect some fake values.

Service Action URL

This url returns "False", which is expected.

+1
source

Source: https://habr.com/ru/post/1529873/


All Articles