2016-03-31 16 views
6

WCF(.svc)サービスをしばらく使用していて、有効なAndroidアプリケーションでは、リクエストフォーマットがJSON、応答フォーマットがXMLです。数日前、私は目的の証明書をDigiCertのWCFサービス(私のワイルドカード機能を使用)で実装しました。このサービスはブラウザからアクセスでき、エラーは表示されません。以下は、同じAndroidのコードを使用している間、応答は常に私がSSLファクトリーを使用してみましたがAndroidでSSLを使用してWCFサービスを使用する

The server cannot service the request because the media type is unsupported. 

であると同様にそれがなくてだから今

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > 
     <section name="IntermediateWebService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </sectionGroup> 
    </configSections> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
     <customErrors mode="Off"/> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="IntermediateWebService.WebBehavior"> 
       <serviceMetadata httpsGetEnabled="true" /> 

       <serviceDebug includeExceptionDetailInFaults="true"/> 
      </behavior> 
     <behavior> 

      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata 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> 
     <endpointBehaviors> 
      <behavior name="WebBehavior"> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="secureHttpBinding" maxBufferPoolSize="524288" maxReceivedMessageSize="999999999"> 
        <security mode="Transport"> 
         <transport clientCredentialType="None"/> 
        </security> 
       </binding> 
      </basicHttpBinding> 
      <webHttpBinding> 
       <binding name="webHttpBindingConfig"> 
        <readerQuotas maxStringContentLength="2048000" /> 
       </binding> 
      </webHttpBinding> 
     </bindings> 
     <services> 

      <service behaviorConfiguration="IntermediateWebService.WebBehavior" name="IntermediateWebService.Service1"> 
       <host> 
        <baseAddresses> 
         <add baseAddress="https://myurl:4445/"/> 
        </baseAddresses> 
       </host> 
       <endpoint address="" binding="basicHttpBinding" contract="IntermediateWebService.IService1" behaviorConfiguration="WebBehavior" bindingConfiguration="secureHttpBinding" /> 
      </service> 
      <!--<service name="IntermediateWebService.Service1"> 
       <endpoint address="" 
     binding="basicHttpBinding" 
     bindingConfiguration="secureHttpBinding" 
     contract="IntermediateWebService.IService1"/> 



      </service>--> 
     </services> 
     <serviceHostingEnvironment multipleSiteBindingsEnabled="false" /> 
    </system.serviceModel> 
<system.webServer> 
    <validation validateIntegratedModeConfiguration="false"/> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

のWebConfigです。私は、エラーを調査したよう

HttpClient client = getHttpsClient(new DefaultHttpClient()); //new DefaultHttpClient(); 

      HttpPost get = null; 
      commandType = params[0].toString(); 
      if ("Login".equals(params[0])){ 

       JSONStringer img = new JSONStringer() 
         .object() 
         .key("value") 
          .object() 
           .key("username").value(params[1].toString()) 
           .key("pwd").value(params[2].toString()) 
           .key("channelID").value(params[3].toString()) 
          .endObject() 
         .endObject(); 
         StringEntity se = new StringEntity(img.toString()); 

       get = new HttpPost("https://" + serverIP + ":" + serverPort + "/Service1.svc/auth"); 
       //get.setHeader("User-Agent", "com.app.new"); 
       get.setHeader("Accept", "application/json"); 
       get.setHeader("Content-Type", "application/json"); 
       get.setEntity(se); 
+1

http://stackoverflow.com/questions/32154115/android-volley-self-signed-https-trust-anchor-for-certification-path-not-found/32219177#32219177またはhttp: //stackoverflow.com/questions/32051482/how-can-i-set-signalr-in-android-studio-to-ignore-ssl-issues-for-delvelopement/32051885#32051885またはhttp://stackoverflow.com/質問/ 32969952/android-to-server-communication-ssl-with-bouncy-castle/32980130#32980130彼らが助けてくれるかどうかを確認してください – BNK

+0

tlsのバージョンはターゲットのAndroidプラットフォームでサポートされていますか? – QiMata

+0

この回答をお試しください。 http://stackoverflow.com/questions/36492885/get-wcf-rest-get-request-in-android –

答えて

0

はステータスコード415を返され、何とかSVCマークアップで次の属性を追加することにより、したがって、JSON有効としてWCFサービスによって受け入れられなかった要求は、トリックをしました

Factory="System.ServiceModel.Activation.WebServiceHostFactory" 

ここ

<%@ ServiceHost Language="C#" Debug="true" Service="IntermediateWebService.Service1" CodeBehind="Service1.svc.cs" 
Factory="System.ServiceModel.Activation.WebServiceHostFactory" %> 

は後で

を完全なソリューションを共有する完全なXMLマークアップです
関連する問題