2016-07-05 5 views
0

WCFサーバーをローカルに開発してテストし、正常に動作します(文字列 "Hello World"を返します)。WCFサービスは.svcのページコンテンツを返します(コンテンツタイプtext/html例外)

GoDaddyでホストされているWebサイトに展開すると、サーバーは "Hello World!"の代わりにService1.svc(説明内容)のページコンテンツを送信します。 。

クライアントの設定:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> 
</startup> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IMessage2" /> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://mywebaddress/myservice/Service1.svc" 
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMessage2" 
      contract="ServiceReference2.IMessage" name="BasicHttpBinding_IMessage2" /> 
    </client> 
</system.serviceModel> 

サーバー設定:

<?xml version="1.0"?> 
<configuration> 

<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 behaviorConfiguration="HelloServiceBehavior" name="HelloService.HelloService"> 
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="" 
     contract="HelloService.IMessage" /> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="HelloServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
     <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> 

</configuration> 

クライアントがクラッシュしたサービス呼び出し方法:フィドラーの

Unhandled Exception: System.ServiceModel.ProtocolException: The content type text/html; charset=utf-8 of the response message doesn't match the content type of the binding 

サービス応答でありますブラウザでwww.XXXXX.com/Service.svcの正確な内容:

<HTML><HEAD><link rel="alternate" type="text/xml" href="http://XXXXXXX.net/myservice/Service1.svc?disco"/><STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>HelloService Service</TITLE></HEAD><BODY><DIV id="content"><P class="heading1">HelloService Service</P><BR/><P class="intro">You have created a service.<P class='intro'>To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:</P> <BR/><PRE>svcutil.exe <A HREF="http://alqasm.net/myservice/Service1.svc?wsdl">http://alqasm.net/myservice/Service1.svc?wsdl</A></PRE><P>You can also access the service description as a single file:<BR/><PRE><A HREF="http://alqasm.net/myservice/Service1.svc?singleWsdl">http://alqasm.net/myservice/Service1.svc?singleWsdl</A></PRE></P></P><P class="intro"/>This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:<BR/><P class='intro'><B>C#</B></P><PRE><font color="blue">class </font><font color="teal">Test 
</font>{ 
<font color="blue"> static void </font>Main() 
    { 
     <font color="teal">MessageClient</font> client = <font color="blue">new </font><font color="teal">MessageClient</font>(); 

<font color="green">  // Use the 'client' variable to call operations on the service. 

</font><font color="green">  // Always close the client. 
</font>  client.Close(); 
    } 
} 
</PRE><BR/><P class='intro'><B>Visual Basic</B></P><PRE><font color="blue">Class </font><font color="teal">Test 
</font><font color="blue"> Shared Sub </font>Main() 
<font color="blue">  Dim </font>client As <font color="teal">MessageClient</font> = <font color="blue">New </font><font color="teal">MessageClient</font>() 
<font color="green">  ' Use the 'client' variable to call operations on the service. 

</font><font color="green">  ' Always close the client. 
</font>  client.Close() 
<font color="blue"> End Sub 
</font><font color="blue">End Class</font></PRE></DIV></BODY></HTML> 

あなたのサポートが非常に高く評価されますが、IISや簡単な修正を使用するため.SVCのMIMEタイプを追加する必要が

+0

GodaddyのIISのバージョンは何ですか? –

+0

@ApurvaSaxena IIS 7.0 – user2209783

+0

@ApurvaSaxena助けてください – user2209783

答えて

0

を登録することができますIISのasp.netリンクmsdn.microsoft.com/en-IN/library/k6h9cz8h(v=vs.100).aspxを参照してください。

+0

私が知る限り、ローカルであれば、IISにasp.netを登録することで問題は解決します。私のローカルバージョンのWCFが実行され、応答がOKです。しかし、問題は私の遠隔Webサービスにあります。 – user2209783

+0

GoDaddyに確認してください、彼らはそれをしていないかもしれませんが、それが事実でないかどうか私に教えてください... –

+0

私は私のWebホスティングをASP.NETに推奨された別の人にホスティングして変更しました。新しいホスティング環境。 GoDaddyはWCFに関しては良い選択ではないようだ。努力のために多くのありがとう – user2209783

関連する問題