I'm currently developing an application in Jaggery which I deploy on their API manager.
From the Jaggery back end I'm calling a SOAP webservice using the method documented here, which specifies:
<%
var url = 'http://jaggeryjs.org/apidocs/resources/home.jag';
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.setRequestHeader("user" , "madhuka");
xhr.send();
print("ReadyState : "+xhr.readyState);
print("<br>ResponseStatus : "+xhr.status);
print("<br>ResponseText : "+xhr.responseText);
%>
I have everything up and working fine, however I'd like to remove the hard-coded URL and replace it with some sort of URL lookup, based on environment.
What is the correct way of doing this? Can I specify an endpoint in API manager and refer to it? Or perhaps use an EPR file. I've had little luck with the Jaggery documentation in this sense.
I have seen many jaggery apps developed for WSO2 products. The practice followed in them is to have a config file in json format. You can have a method to read it and get necessary values by passing the attribute name.
You can either have a config file for each environment and pack the correct one with the app or have a single config file with endpoints for each environment. If you are going to maintain a single config file, you have to dynamically construct the attribute name and read its value. To do that also, you need to maintain which environment it is. Therefore I recommend to use a config file for each environment and bundle the correct file for the environment.
Related
I am creating a postman collection for one of API integration with our Service. Here we are using OAuth1.0 for authentication. I want to set the oauth init response oauth_token, oauth_token_secret into postman environment variables so that I can access them in further requests.
The response is in below format not a JSON.
oauth_token=oauth_token_value&oauth_token_secret=oauth_token_secret_value&oauth_callback_confirmed=true
I tried below script:
var output = require('querystring').parse(Response.text);
postman.setGlobalVariable("oauth_token", output.oauth_token);
postman.setGlobalVariable("oauth_token_secret", output.oauth_token_secret);
Can some one help me to set tokens into postman environment variables please.
Note: I am using chrome plugin Version 5.5.4, not native app.
In the chrome extension you need to use postman.setEnvironmentVariable():
postman.setEnvironmentVariable("oauth_token", output.oauth_token);
postman.setEnvironmentVariable("oauth_token_secret", output.oauth_token_secret);
For that you need to have an environment created and selected (no need to add any variable manually). How to do that is described here: https://learning.postman.com/docs/sending-requests/managing-environments/#creating-environments
I am trying to learn webservices in .NET mvc4. I tried creating a new Internet application and adding a Web service (asmx) to the project.
By default, the VS adds a "HelloWorld" Webservice. When I try to run it in the browser, I do get the list of operations, service description(WSDL) and the details of the HellowWorld operation. However, when I try invoking the webservice, it gives the following error :
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make
sure that it is spelled correctly.
I might be missing some basic step/setting I guess. Could some body help please. Thanks.
I got the answer from one of my colleagues :) .
When we invoke the service, the MVC tries to resolve the path as specified in RegisterRoutes.
Hence it tries to find a controller with that name and a method with the name same as that of the operation inside that controller. The resolution, ignore the paths with .asmx extension. You can do that by adding the following line in RouteConfig.cs :
routes.IgnoreRoute("{*x}", new { x = #".*\.asmx(/.*)?" });
and it worked. Thanks.
I have an app written using MonoTouch that relies on a Web Services URL backend. I need the ability to set the URL of this backend dynamically at run time from within the app (or from within it's settings).
I've read this article on CodeProject that describes setting URL dynamically:
http://www.codeproject.com/Articles/12317/How-to-make-your-Web-Reference-proxy-URL-dynamic#_rating
But I can't find this option in MonoDevelop.
I've tried altering the Url property of my service, but it appears there is more to it than that. (Specifically the "references.cs" file added by the web service seems to also have the URL hard coded in various attributes).
Any help much appreciated.
Thanks!
--scotru
When Mono generates C# wrapper for SOAP web-service to you, it creates 2 constructors of wrapper. Second one contains URL parameter, which you can use to set proper URL and so switch between web-services.
Example from project, which is in production (file Reference.cs):
public partial class ServicesInfoImplService : System.Web.Services.Protocols.SoapHttpClientProtocol
...
public ServicesInfoImplService() {
this.Url = "<DEFAULT_URL>";
}
public ServicesInfoImplService(string url) {
this.Url = url;
}
...
I've been provided a WSDL file that points to a webservice. I use this webservice to log in and create a session. In addition to the session token, the login response provides a URL I'm supposed to redirect my webservice calls to. Other than the URL I'm addressing, the definitions are the same, so no new WSDL is provided.
What is the best way to handle this? Generate my own altered WSDL? Create and/or alter the webservice object via Java? Some third option I've not thought of?
This is a hack, but you can always download the WSDL as a template, and reference it as a local file. When the login call tells you what URL to hit, simply replace the URL in the template with the new one, and proceed. You could even have a different version of the WSDL for each URL that could be returned, maybe using a hash of the URL as the filename.
Coldfusion webservice invocations always point to WSDL. Be it a local WSDL file, or a remote WSDL file you can access over an HTTP or HTTPs connection. Unless the responding URL points to a new WSDL file to use, it's not going to be that helpful.
-Jay
I'm trying to built a SharePoint Web Part that has as part of it a service reference to Another SharePoint server that I need to call from within vb code. However when I try to call the remote web service for the first time, I get the following in the log:
Could not find default endpoint element that references contract 'ListReference.ListsSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.EndpointTrait1.CreateSimplexFactory()
at System.ServiceModel.ClientBase1.CreateChannelFactoryRef(EndpointTrait1 endpointTrait)
at System.ServiceModel.ClientBase1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase1..ctor()
at VSeWSS.ChangeRequestWorkflow.ChangeRequest.SubmitForm(Object sender, EventArgs e)
What is the proper way to deploy a Web Part with a Service Reference, could I be doing something wrong? Thanks!
You need to add the endpoint configuration into the web.config of the SharePoint site that is consuming the webservice.
I found this question that solved my problem.
Basically, I just needed to create a BasicHttpBinding object and populate its properties with the ones the SVC generator made in my app.config.
WCF Configuration without a config file
Actually I solved my problem. My application has many projects, and the config file was in the project calling the WebService, but it seems it has to be in the starting project...
Hm, if I'm understanding what you're asking correctly, I'm doing that. I just added the webservice from one of the correct endpoints to the project in VS, then before I call it in my actual code, I get the URL I want to connect to with this call from the hierarchical object store from Codeplex, then set the Url property. So:
MyService srv = new MyService();
srv.Url = SPContext.Current.Web.Properties["serviceurl"];
Its working like that fine.
hth.