I have an issue that hopefully someone could advise me on.
I am creating an enterprise iPhone application that will capture information and write it to a local server.
Depending on which of our sites the user is at will depend on which server the information is written to.
I have created a webservice which I can consume in monotouch and pass it information which it will then write to a SQL database on the local server. The problem I face is how do I go about doing this for all of our locations? If i put a web service at each location then each location will need its own version of the app that write using their webservice (all the servers are on the same network and are not separate)
Can I dynamically consume a webservice by passing the relevant URL?
Should I be taking another approach?
Any advice would be appreciated.
EDIT - I probably should mention we use WCF-style web services that require bindings being generated with SISvcUtil.exe (that is where the WebServiceClient class comes from).
We do something similar where we have a test server and production server and it is simple to change the URL where the web service points to. Obviously this does assume that the web service hosted at all the different locations are the same...
When creating the Client object which consumes the web service you need to specify bindings and an endpointaddress, you can simply change the endpointaddress string to point at the appropriate server. The code below should give you an idea of how to do this...
BasicHttpBinding binding = new BasicHttpBinding();
binding.OpenTimeout = new TimeSpan(0,1,0);
binding.CloseTimeout = new TimeSpan(0,1,0);
binding.SendTimeout = new TimeSpan(0,1,0);
//snip - any other bindings you need to specify...
string fullDomain;
string domain;
if (local)
domain = "local.server.com";
else
domain = "production.server.com";
fullDomain = string.Format("https://{0}/WebService/Service.svc", domain);
EndpointAddress endpointAddress = new EndpointAddress(fullDomain);
WebServiceClient client = new WebServiceClient(binding, endpointAddress);
Yes. There should be either a constructor or a Url property you can set which enables you to pass the URL to your different service endpoints at runtime.
(I presume here that you are talking about multiple instances of the same web service hosted at different URLs)
Related
I did redirect to external link in asp.net core in local
public async Task<IActionResult> Fallback(string transactionId, [FromForm] FallbackRequest fallbackRequest)
{
var result = await _opayoPaymentService.FallbackRequest(transactionId, fallbackRequest);
return Redirect($"http://localhost:4200/payment-done/{transactionId}/{result.Status}");
}
http://localhost:4200/ this is local on local environment (Angular project).
Now, the Angular project is on production. The url is http://production-url/
Now I want to redirect the production url.
How can I add both urls? When the project runs in production, then production url should be redirected, when the project runs locally, then localhost url should be redirected.
Your description reminded me the appsetting.json and appsetting.development.json, you can set your url as a variable in the configuration file and use it in your code rather than hard-coding the url into your code. Here's a high vote answer based on this scenario, it also provides some related documents in it.
What I wanna add here is some other ways. First, you can also define the url as a variable, which obtain the value from the server's environment variable, it requires you to set an environment variable before deploy your application.
Another way is storing the url into your database and create a management website to modify the value if it needs to be changed. This method is suitable for those application which already has some management page or is about to design management module for the whole application. The advantage is really flexible and easy to change, such as the web url is changed due to some reason so your app need to change the url corresponding to it. As you know some application really needs to do much configuration when it's running.
I have an application in the service fabric and I'm going to upload another one.
I wonder if it's possible to assign different names to each application.
With an application, I access using the address:
http://sf-spartan.eastus.cloudapp.azure.com
You can configure for access to look like this:?
http://application1.sf-spartan.eastus.cloudapp.azure.com
or
http://sf-spartan.eastus.cloudapp.azure.com/application1
Sure, have a look here. Use the ApplicationName argument to define it.
Every application instance you create must in fact have a unique name.
You can reach your application instance through its url by using a reverse proxy. (either the built-in one, or a custom one like Traefik)
Usually, the application and service name are part of the url, e.g.:
http://mycluster.eastus.cloudapp.azure.com:19081/MyApp/MyService
This does require a web based communication listener.
Event more info here.
I am writing/testing a server side plug-in and am looking to derive if this is running on our development or production TFS instance to allow me to drive a slightly different process (e.g. add some obvious text to any email subjects that it sends out to ensure that people know it has derived from the development instance).
There is a "IsProduction" property that I can access via the requestContext variable (IVSSRequestContext.ServiceHost.IsProduction - was previously TeamFoundationRequestContext.TeamFoundationServicehost.IsProduction before TFS2015), but this property is set to true in both instances.
Does anyone know if/should this can be used for that purpose and if so, how it can be set as I can't find any documentation online and can't see anything obvious in the TFS Admin Console.
No, but I suggest using a global Environment variable (e.g. IsDevelopment).
Another option is to get the server URL (see code snippet) and use it to determine the environment, but I think it is less safe.
private Uri GetCollectionUriFromContext(IVssRequestContext requestContext)
{
ILocationService service = requestContext.GetService<ILocationService>();
return service.GetSelfReferenceUri(requestContext,
service.GetDefaultAccessMapping(requestContext));
}
I'm fairly new to Spring Boot, but I want to want to build my application in such a way, that can deploy mulitple applications on the same server and i want to distinguish the applications in the rest path.
For example, say i have the applications user-management and animal-management and i have a rest-controller in both of them responding to the path \names.
Both those applications run on localhost:8080 so when sending a GET to localhost:8080/users/names, I want the controller of the user-management to react and the same for animal with a GET to localhost:8080/animals/names.
I can put a #RequestMapping on the controller to acchieve the names part, but if i do the same on the application, it gets ignored.
Basically I want to tell my application "Every controller in this application should be mapped to the rest path specified on the controller, but prefixed with 'x'".
How can I do that.
I was looking for the contextPath, I just didn't know the name.
By putting the server.contextPath=/users attribute in the application.properies it worked like i wanted to.
Thank you #Vaionixx
I have a play application that uses subdomains.
Currently I have dns setup on my laptop so I can browse URLS locally like:
subdomain1.myappurl.com:9000/
subdomain2.myappurl.com:9000/
(I have myappurl pointing to 127.0.0.1).
I want to create a test now that uses these URLS (I want to provide the URL)
How can I do this with FakeRequest?
Also, what is FakeRequest, is it a headless browser? I ideally want to create a integration test (but not testing the UI side of things) to make sure data is correctly written to the database when I login/logout etc.
Edit: In light of the OP's comments, there is a way to override the host name in the FakeRequest, by adding it as a header. It appears that request.host is actually set in the Request trait where it's just derived from the headers.
import play.api.http.HeaderNames
FakeRequest(GET, "/something").withHeaders(HeaderNames.HOST -> "sub.domain.com")
The FakeRequest is just passed through the router of theFakeApplication(if using theroutehelper), and what you get is theResult` from the controller function. No headless browser involved here.
What will use a headless browser is the WithBrowser helper.
"go to the right url" in new WithBrowser(webDriver = WebDriverFactory(HTMLUNIT)) {
browser.goTo("google.com")
browser.pageSource must not contain("Bing")
// Do other things ...
}
WithBrowser is kind of overkill for testing whether or not data has been saved.