2012-01-17 5 views
1

以下の設定でAzureでwebroleとしてホストされているWCFアプリケーションがあります。ブラウザで3つのサービスwsdlのいずれかにアクセスしようとしているとき、またはプロキシを設定しようとしているときに、400 Bad Requestが発生しています。このWCF設定が400の悪い要求を引き起こしていますか?

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

     <appSettings> 
     </appSettings> 

     <system.web> 
      <customErrors mode="Off"></customErrors> 
      <compilation debug="true" targetFramework="4.0" /> 
     </system.web> 

     <connectionStrings></connectionStrings> 

     <system.diagnostics>  
     <sharedListeners> 
      <add name="AzureLocalStorage" type="Example.AzureLocalStorageTraceListener, Example"/> 
     </sharedListeners> 
     <sources> 
      <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing"> 
      <listeners> 
       <add name="AzureLocalStorage" /> 
      </listeners> 
      </source> 
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose"> 
      <listeners> 
       <add name="AzureLocalStorage" /> 
      </listeners> 
      </source> 
     </sources> 
     </system.diagnostics> 

     <system.serviceModel> 
      <services> 
       <service name="Service1" behaviorConfiguration="MetaBehavior"> 
        <endpoint address="http://example.com/service1.svc" binding="basicHttpBinding" name="basicEndpoint1" contract="IService1" /> 
       </service> 
       <service name="Service2" behaviorConfiguration="MetaBehavior"> 
        <endpoint address="http://example.com/service2.svc" binding="basicHttpBinding" name="basicEndpoint2" contract="IService2" /> 
       </service> 
       <service name="Service3" behaviorConfiguration="MetaBehavior"> 
        <endpoint address="http://pexample.com/service3.svc" binding="basicHttpBinding" name="basicEndpoint3" contract="IService3" /> 
       </service> 
      </services> 
      <behaviors> 
       <serviceBehaviors> 
        <behavior name="MetaBehavior"> 
         <serviceDebug includeExceptionDetailInFaults="true" /> 
         <serviceMetadata httpGetEnabled="true"/> 
         <serviceThrottling maxConcurrentSessions="90" /> 
        </behavior> 
       </serviceBehaviors> 
      </behaviors> 
      <serviceHostingEnvironment multipleSiteBindingsEnabled="false" aspNetCompatibilityEnabled="true" /> 
     </system.serviceModel> 

     <system.webServer> 
      <modules runAllManagedModulesForAllRequests="true"/> 
     </system.webServer> 

    </configuration> 

私の設定が正しくないと確信していますが、私は間違っているものについて少しガイダンスが必要です。

インターフェースは次のように定義されて:あなたは間違っバインディングを使用している

[ServiceContract(Name = "Service1", Namespace = "http://example.com")] 
public interface IService1 
{ 
    [WebGet] 
    [OperationContract] 
    Result Create(); 
} 

答えて

3

、basicHttpBindingの代わりにwebHttpBindingしてみてください。あなたの契約はWebGetに設定されています。WebGetはWCFの準RESTベースのサービスです。 BasicHttpBindingは、SOAPベースのバインディングのみに使用されます(したがって、「不正要求」例外)。

編集: WebGetが存在していたので、私はあなたが石鹸のエンドポイントを望んでいないと思っていました。以下はsoapとWebGetの両方をサポートする設定です。 Azureが標準IISからどのように異なっているのか分かりませんが、おそらくという相対的なアドレスを使用してください。 IISは、サービス設定の相対アドレスのみをサポートします。

<system.serviceModel> 
    <services> 
     <service name="Service1" behaviorConfiguration="Service.Behavior"> 
      <endpoint address="Service1" 
         binding="basicHttpBinding" 
         contract="IService1" 
         bindingNamespace = "http://example.com" 
         bindingConfiguration="HttpBasic" /> 
      <endpoint address="mexService1" 
         binding="mexHttpBinding" 
         contract="IMetadataExchange" 
         bindingNamespace = "http://example.com"/> 
      <endpoint address="webService1" 
         binding="webHttpBinding" 
         behaviorConfiguration="webBehavior" 
         contract="IService1" 
         bindingNamespace = "http://example.com" 
         name="webHttp" 
         listenUriMode="Explicit" /> 
     </service> 
     <service name="Service2" behaviorConfiguration="Service.Behavior"> 
      <endpoint address="Service2" 
         binding="wsHttpBinding" 
         contract="IService2" 
         bindingNamespace = "http://example.com" 
         bindingConfiguration="HttpStandard" /> 
      <endpoint address="mexService2" 
         binding="mexHttpBinding" 
         contract="IMetadataExchange" 
         bindingNamespace = "http://example.com"/> 
      <endpoint address="webService2" 
         binding="webHttpBinding" 
         behaviorConfiguration="webBehavior" 
         contract="IService2" 
         bindingNamespace = "http://example.com" 
         name="webHttp" 
         listenUriMode="Explicit" /> 
    </services>  
    <behaviors> 
     <endpointBehaviors> 
      <behavior name="webBehavior" > 
       <webHttp /> 
      </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
      <behavior name="Service.Behavior"> 
       <serviceMetadata httpGetEnabled="true"/> 
       <serviceDebug includeExceptionDetailInFaults="false"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="HttpBasic" receiveTimeout="00:10:00" maxReceivedMessageSize="2048000"> 
       <security mode="None"/> 
      </binding> 
     </basicHttpBinding> 
     <wsHttpBinding> 
      <binding name="HttpStandard" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2048000"> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
        <message clientCredentialType="None" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" /> 
       </security> 
      </binding> 
      <binding name="Https" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2048000"> 
       <security mode="Transport"> 
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
        <message clientCredentialType="None" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" /> 
       </security> 
      </binding> 
      <binding name="HttpsAuthenticated" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2048000"> 
       <security mode="Transport"> 
        <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
</system.serviceModel> 
+0

SOAPを使用する場合、正しい構成は何ですか? – Digbyswift

+1

soapとWebGetの両方をサポートするようにWCFを設定できます。私は答えを広げました。 –

関連する問題