1

Azure Web ロールでホストされる WCF サービスを作成しようとしています。このサービスは、soap and rest によって到達可能でなければなりません。

私はいくつかの記事を読んでいて、すべての仕様を備えたサービスを作成することができました (少なくとも私はそう思っていました)。

私がやろうとしているのは、残りのエンドポイントを SoapUI プロジェクトで消費し、すべてのパラメーターを含むクエリ文字列で POST を実行することですが、このプロジェクトを実行すると、次のような応答が得られます。

サーバーでリクエストの処理中にエラーが発生しました。例外メッセージは、「操作 'CPlano' の要求メッセージの本体を逆シリアル化中にエラーが発生しました。メッセージが空 (IsEmpty = true) であるため、OperationFormatter はメッセージからの情報を逆シリアル化できませんでした。

ここに私の Web.Config の一部があります:

<bindings>
  <webHttpBinding>
    <binding name="webBinding" maxReceivedMessageSize ="50000000" maxBufferPoolSize="50000000">
      <readerQuotas maxDepth="500000000" maxArrayLength="500000000" maxBytesPerRead="500000000"
                    maxNameTableCharCount="500000000" maxStringContentLength="500000000"/>
      <security mode="None" />
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="RestBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above 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="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="Namespace.CService" behaviorConfiguration="ServiceBehavior">
    <endpoint name="RESTEnpoint" contract="Namespace.ICService" binding="webHttpBinding" bindingConfiguration="webBinding" bindingNamespace="http://www.example.com/" address="rest" behaviorConfiguration="RestBehavior" />
    <endpoint name="SOAPEndpoint" contract="Namespace.ICService" binding="basicHttpBinding" bindingNamespace="http://www.example.com/" address=""></endpoint>
  </service>
</services>

また、ここに私のサービスインターフェイス宣言があります:

[ServiceContract(Namespace = "http://www.example.com/")]
public interface ICService
{
    [OperationContract]
    [WebInvoke(UriTemplate = "/CPlano",
    BodyStyle = WebMessageBodyStyle.Wrapped,
    Method = "POST")]
    RespuestaCotizador CPlano(int idUsuario, string usuario, string pass, int modalidad, int servicio,
        int medicion, string paisDestino, int envio, decimal peso, decimal largo, decimal ancho, decimal alto);
}

そして最後に私の応答クラス:

[DataContract(Namespace = "http://www.example.com/")]
public class RespuestaCotizador
{
    [DataMember]
    public bool HasError;
    [DataMember]
    public string ErrorMessageESP;
    [DataMember]
    public string ErrorMessageENG;
    [DataMember]
    public decimal PrecioCotizado;

    public RespuestaCotizador()
    {
        HasError = false;
        ErrorMessageESP = string.Empty;
        ErrorMessageENG = string.Empty;
        PrecioCotizado = 0;
    }
}

依存性注入にユニティを使用していますが、これは関係ないようです。

サービスをローカルで実行している場合でも、最初のブレークポイントに到達できます。

4

1 に答える 1

0

SOAP または REST を使用しますか? SOAP を使用する場合は、BasicHttpBinding などの別のバインディングを使用してください。WebHttpBinding は通常、REST サービスに使用されます。REST を使用する場合は、idUsuario や usuario のようにすべてをカプセル化するクラスを作成できます。単一のパラメーターを受け入れるようにサービス メソッドを構成します: 新しいクラス。次に、POST を実行するときに、シリアル化されたオブジェクトを要求本文として渡します。さらに、WCF テスト クライアントを使用して REST サービスを利用することはできません。SOAP のみで対応します。ただし、Fiddler を使用することはできます。または (新しいサービスに推奨)、WCF の代わりに ASP.NET Web API を使用して REST サービスを構築します。

于 2012-07-25T11:58:25.720 に答える