2017-08-02 37 views
0

我正在開發WCF Web服務。我創建了一個服務,當我運行該服務時,我沒有看到列出的任何方法。WCF方法名稱在運行應用程序時未顯示

我附上截圖:

Missing method name

這是我所創建的服務和方法:

XML請求

<?xml version="1.0"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
<SOAP-ENV:Body> 
<opportunityID>1-1DA7KN</opportunityID> 
<opportunityStatus>Created</opportunityStatus> 
<opportunityserviceType>LEASE_REQUEST</opportunityserviceType> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 
[ServiceContract] 
public interface IOpportunity 
{ 
    [OperationContract] 
    [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, 
    UriTemplate = "postmethod/updateOpportunity")] 
    bool updateOpportunity(opportunityActivity obj); 
} 

[DataContract] 
public class opportunityActivity 
{ 
    [DataMember] 
    public string opportunityID { get; set; } 
    [DataMember] 
    public string opportunityStatus { get; set; } 
    [DataMember] 
    public string opportunityserviceType { get; set; } 
} 

這是我web.config文件:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5.2" /> 
    <httpRuntime targetFramework="4.5.2" /> 
    <httpModules> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> 
    </httpModules> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="RayaSoapService.Opportunity"> 
     <endpoint address="" contract="RayaSoapService.IOpportunity" binding="basicHttpBinding"/> 
     <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 

     </serviceBehaviors> 

    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 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> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true" /> 
    <validation validateIntegratedModeConfiguration="false" /> 
    </system.webServer> 
    <connectionStrings> 
    <add name="Test_ROLSP_DB_V1Entities" connectionString="metadata=res://*/Model.ModelModel.csdl|res://*/Model.ModelModel.ssdl|res://*/Model.ModelModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.168.0.210;initial catalog=Test_ROLSP_DB_V1;user id=sa;[email protected];MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
</configuration> 

上面的代碼工作正常。我使用網絡客戶端進行了測試。現在我想把這個暴露給一些第三方,所以我應該給他們XML格式。我無法弄清楚如何獲得上述服務的XML格式?每當我運行服務時,我都無法看到頁面上列出的方法。有人可以幫助我獲得上述請求的XML嗎?任何幫助將不勝感激。謝謝

+0

如果您可以發佈app.config端點,它將會足夠清楚。 –

回答

1

您需要添加MEX端點行爲配置,我想你錯過了它。

<services> 
     <service name="RayaSoapService.Opportunity" 
behaviorConfiguration="mexBehaviour"> 
     <endpoint address="" contract="RayaSoapService.IOpportunity" binding="basicHttpBinding"/> 
     <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="mexBehaviour"> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" /> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 

     </serviceBehaviors> 
+0

謝謝。我發佈了我的web.config文件。我可以知道我在上面的代碼中缺少什麼嗎? –

+0

根據你的web.config文件修改@NiranjanGodbole。 –

+0

謝謝Hameed。我已經添加,它運行沒有錯誤。但我沒有得到任何方法名稱列出。 –

相關問題