मैं कैसे पता लगा सकता हूं कि GetAccounts को ट्रिगर करने के लिए मुझे किस एंडपॉइंट का अनुरोध करना चाहिए?सेवा कपड़े पर एप्लिकेशन कैसे ब्राउज़ करें?
मैं अपने स्थानीय क्लस्टर पर चल रहे दो आवेदन मिल गया है:
कपड़े/सेवा निम्नलिखित विन्यास के साथ एक वेब एपीआई अनुप्रयोग है:
internal sealed class Web : StatelessService
{
public Web(StatelessServiceContext context)
: base(context)
{
}
/// <summary>
/// Optional override to create listeners (like tcp, http) for this service instance.
/// </summary>
/// <returns>The collection of listeners.</returns>
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[]
{
new ServiceInstanceListener(serviceContext => new OwinCommunicationListener(Startup.ConfigureApp,
serviceContext, ServiceEventSource.Current, "ServiceEndpoint"))
};
}
}
स्टार्टअप को इस प्रकार कॉन्फ़िगर किया गया है:
public static class Startup
{
// This code configures Web API. The Startup class is specified as a type
// parameter in the WebApp.Start method.
public static void ConfigureApp(IAppBuilder appBuilder)
{
// Configure Web API for self-host.
var config = new HttpConfiguration();
//config.Routes.MapHttpRoute(
// name: "DefaultApi",
// routeTemplate: "api/{controller}/{id}",
// defaults: new { id = RouteParameter.Optional }
//);
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
config.MapHttpAttributeRoutes();
var container = new UnityContainer();
container.RegisterType<IAccountService, AccountService>(new HierarchicalLifetimeManager());
config.DependencyResolver = new UnityResolver(container);
appBuilder.UseWebApi(config);
}
}
और अंत में सेवा प्रकट:
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="WebPkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="WebType" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>removed...........Accounts.Web.exe</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" />
</Endpoints>
</Resources>
</ServiceManifest>
और मेरे नियंत्रक:
[HttpGet]
[Route("accounts", Name = "GetAccounts")]
public async Task<IHttpActionResult> GetAccounts(){//dostuff}
मुझे कैसे पता चलेगा कि क्या endpoint मैं आदेश GetAccounts को गति प्रदान करने में का अनुरोध किया जाना चाहिए?
पीटर, इतना धन्यवाद तुम्हारी मदद के लिए। मैंने ठीक वही किया जैसा आपने सुझाव दिया था, लेकिन कोई नहीं जाना: https://lh3.googleusercontent.com/-QqFCDujEYys/WSiH1wpAaSI/AAAAAAAAC3E/iijNazjURZw3TCJQHSFH1UKovtYErkHrwCHM/s0/2017-05-26_14-53-42.gif –
@MeggieLuski त्रुटि इंगित करता है कि पहले से ही पोर्ट 80 पर कुछ और सुन रहा है। इसे कैब काम देखने के लिए पहले पोर्ट नंबर 81 को बदलने का प्रयास करें और फिर उस अन्य प्रक्रिया को देखें। क्या आप आईआईएस या कुछ स्थानीयहोस्ट पर चल रहे हैं? –
मैं 81, 82, 83 आदि में बदल गया हूं, और एक ही परिणाम। –