以下の REST API の実装があります。
using System.Web.Http;
public class DeploymentsController : ApiController
{
public HttpResponseMessage Post(
string subscriptionId,
string serviceName,
string deploymentSlot,
CreateDeploymentInput input)
{
. . .
}
public HttpResponseMessage Post(
string subscriptionId,
string serviceName,
string deploymentSlot,
UpdateDeploymentStatusInput input)
{
. . .
}
}
これはルーティングです:
config.Routes.MapHttpRoute(
name: "DeploymentSlots",
routeTemplate: "{subscriptionId}/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlot}",
defaults: new
{
controller = "deployments",
});
config.Routes.MapHttpRoute(
name: "Deployments",
routeTemplate: "{subscriptionId}/services/hostedservices/{serviceName}/deployments/{deploymentName}",
defaults: new
{
controller = "deployments"
});
以下のような新しい「アップグレード」アクションの処理を追加したかったのです。
POST /1d42d489-7a4f-4561-91a3-c2033c31f8c6/services/hostedservices/Mytalk123490193975/deployments/Mytalk12349019/?comp=upgrade HTTP/1.1
Content-Type: application/xml; charset=utf-8
x-ms-version: 2012-08-01
Host: localhost:33344
Content-Length: 340
Expect: 100-continue
Accept-Encoding: gzip, deflate
HTTP/1.1 100 Continue
<UpgradeDeployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="ht tp://www.w3.org/2001/XMLSchema-instance"><Mode>auto</Mode><PackageUrl>http://
talkserviceshared.blob.core.windows.net/mycontainer/PackageTXlCaXp0YWxrMTIzNDkwMTkzOTc1
そこで、ApiController にハンドラーを追加しました。
public HttpResponseMessage Post(
string subscriptionId,
string serviceName,
string deploymentSlot,
UpgradeDeploymentInput input)
{
. . .
}
しかし、クライアントを使用してそれを呼び出すと、「リクエストに一致する複数のアクションが見つかりました」と不平を
言っ
た、UpdateDeploymentStatusInput 入力)
次に、メソッドを 1 つにまとめてみました。
public HttpResponseMessage Post(
string subscriptionId,
string serviceName,
string deploymentSlot,
object input)
{
}
また、ランタイム タイプをチェックしてさまざまなアクションを実行するコードを記述しました。しかし、今回は System.InvalidOperationException で呼び出しが失敗します
私が自分自身を撃つ前に助けてください。このようなことを一から学ぶ時間はありません。時間に追われています。