Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从同一服务运行特定方法时未找到终结点_C#_Wcf - Fatal编程技术网

C# 从同一服务运行特定方法时未找到终结点

C# 从同一服务运行特定方法时未找到终结点,c#,wcf,C#,Wcf,我正在尝试运行一个WCF服务,但是当我尝试调用一个特定的服务方法时,我得到了一个错误 未找到终结点 在第三方托管服务器上托管后 这是我的.SVC.cs代码 public class AUTOHUBWITHSQL : IAUTOHUBWITHSQL { ClsDataAccess ObjData = new ClsDataAccess(); public Responce Login(string sEmail, string sPassword)

我正在尝试运行一个WCF服务,但是当我尝试调用一个特定的服务方法时,我得到了一个错误

未找到终结点

在第三方托管服务器上托管后

这是我的
.SVC.cs
代码

public class AUTOHUBWITHSQL : IAUTOHUBWITHSQL
{
        ClsDataAccess ObjData = new ClsDataAccess();

        public Responce Login(string sEmail, string sPassword)
        {
            Responce responce = new Responce();
            string sJson = "";

            try
            {
                sJson = ObjData.GetData("EXEC ProcLogin @email='" + sEmail + "',@Password='" + sPassword + "',@flag='L'");
                responce.Data = sJson;
                responce.Success = true;
                responce.Error = "";
            }
            catch (Exception ex)
            {
                sJson = ex.Message.ToString();
            }

            return responce;
        }

        public Responce AlterCustomerDocument(string data)
        {
            Responce responce = new Responce();
            string sJson = "";

            try
            {
                CustomerDocument cusdoc = JsonConvert.DeserializeObject<CustomerDocument>(data);
                string sProstring = "EXEC ProcCustomerDocument @id='" + cusdoc.id + "',@Userid='" + cusdoc.Userid + "',@VehiclelNo='" + cusdoc.VehiclelNo + "'";
                sProstring += ",@VehicleType='" + cusdoc.VehicleType + "',@DocumentType='" + cusdoc.DocumentType + "',DocumentName='" + cusdoc.DocumentName + "' ,@flag='L'";
                sJson = ObjData.AlterDB(sProstring);

                if (sJson.Equals("Sucess"))
                {
                    responce = GETCustomerDocument(Convert.ToInt32(cusdoc.Userid));
                }

                responce.Success = true;
                responce.Error = "";
            }
            catch (Exception ex)
            {
                sJson = ex.Message.ToString();
            }

            return responce;
        }

        public Responce GETCustomerDocument(int iUserid)
        {
            Responce responce = new Responce();
            string sJson = "";

            try
            {
                string sProstring = "EXEC ProcCustomerDocument @Userid='" + iUserid + "',@flag='S'";
                sJson = ObjData.GetData(sProstring);
                responce.Data = sJson;
                responce.Success = true;
                responce.Error = "";
            }
            catch (Exception ex)
            {
                sJson = " Faild";
                responce.Error = ex.Message.ToString() + sJson;
            }

            return responce;
        }
}
IAUTOHUBWITHSQL
中,
Login
方法工作正常,但在运行post2方法时,我遇到了这个“未找到端点”错误

这是我的
web.config
文件:

<configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.0" defaultLanguage="c++7">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
</system.web>
<system.serviceModel>
    <services>
        <service name="AutoHubWITHSQL.AUTOHUBWITHSQL" 
                 behaviorConfiguration="serviceBehavior">
            <endpoint 
                address="" 
                binding="webHttpBinding" behaviorConfiguration="jsonBehavior" 
                contract="AutoHubWITHSQL.IAUTOHUBWITHSQL" />
            <!--
            <endpoint 
                address=""
                binding="webHttpBinding" behaviorConfiguration="web"
                contract="AutoHub.IAutoHubService">
            </endpoint>
            -->
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="serviceBehavior">
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <!--
            <behavior name="web">
                <webHttp/>
            </behavior>
            -->
            <behavior name="jsonBehavior">
                <webHttp />
            </behavior>
            <behavior name="webBehavior">
                <webHttp helpEnabled="true" 
                         automaticFormatSelectionEnabled="false" />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <extensions>
        <behaviorExtensions>
            <add name="crossOriginResourceSharingBehavior" 
                 type="AutoHub.EnableCrossOriginResourceSharingBehavior, AutoHub, Version=1.0.0.0, Culture=neutral" />
        </behaviorExtensions>
    </extensions>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
    <directoryBrowse enabled="true" />
    <validation validateIntegratedModeConfiguration="false" />
    <httpProtocol>
      <customHeaders>
      </customHeaders>
    </httpProtocol>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>

首先,您没有任何基址,因此需要添加一个。假设一个地址

 <host>
         <baseAddresses>
          <add baseAddress="http://localhost:8080/" />
         </baseAddresses>
        </host>

由于您的地址为“”,这意味着默认情况下只能访问一个端点,请提供地址的相对名称

      <endpoint 
                address="HubSQL" 
                binding="webHttpBinding" behaviorConfiguration="jsonBehavior" 
                contract="AutoHubWITHSQL.IAUTOHUBWITHSQL" />
            <!--
            <endpoint 
                address="Hubservice"
                binding="webHttpBinding" behaviorConfiguration="web"
                contract="AutoHub.IAutoHubService">
            </endpoint>


没有任何端点的主机或基址,登录如何工作?@hameed您能帮我解决此问题吗?添加端点地址后,显示404错误地址未找到。请删除对web行为的注释。
      <endpoint 
                address="HubSQL" 
                binding="webHttpBinding" behaviorConfiguration="jsonBehavior" 
                contract="AutoHubWITHSQL.IAUTOHUBWITHSQL" />
            <!--
            <endpoint 
                address="Hubservice"
                binding="webHttpBinding" behaviorConfiguration="web"
                contract="AutoHub.IAutoHubService">
            </endpoint>
    <behavior name="web">
        <webHttp/>
    </behavior>