H!,
I have a solution in which there is several other sub projects (windows application).
in every project I have some web services added.
Now the problem :
how can i set the URL of each web service individually from the app.Config file??
is there a setting I missed to set ?
can it be automatically done or I have to code for it ?
Thank you friends.
There is only 1 app.Config file per executable - although the app.Config file is named app.Config in the solution, it is in fact renamed to the same name as the end executable:
So for example if my output executable is called Test.exe, the app.Config file will be named Test.exe.config.
Only config in that file has an effect - thats the file you need to set your web service URL in.
Related
I used the CN1 Webservice Wizard to add a the webservice proxy to my mobile app and to generate all the server side code. I have a local XAMPP installation with a tomcat linked within my Eclipse IDE. Also, I imported the server generated code as a new Java Project and added the "Dynamic Web Module" project facet to it so that I could launch it not as a local Java application but rather on the Tomcat server.
When starting my client, I noted that I get HTTP 404, resource not found errors. I traced the error back to the URL, where the server is hosted to.
I know I have to adapt the urlPatterns parameter in the generated class CN1WebServiceServlet, which I did. Also, I checked the context of my app in the Web project settings and defined the value for context root. So, in my client app, the URL to call the service should be
http://localhost:8080/< context root>/< urlPattern>
However, even when calling that in the browser, I should get the result of the doGet method of the server generated code, showing the message "Webservice access only". Instead, I get 404 errors all the time.
Is there some problem to importing the server generated code as a plain Java project and adding the web parts to it afterwards? How would that be done in the ideal case?
And what other problems might be hindering the URL from properly being published on the server side?
Thanks and best regards
EDIT
I stripped everything from the project to limit the options and I found the cause: when using the web service wizard to dump the source files into a new directory, adding that with the Eclipse import wizard, it will be looked at as a plain java project without any web components. Using the project settings to add the dynamic web piece to it (Eclipse calls those project facets), the CN1 webservice will NOT work.
If instead you create a "Dynamic Web Project" first and then use the CN1 Webservice Wizard to dump the server source files into the "src" folder of that project, it works without any issues.
I have created a little example app to test out the CN1 web service functionalities. Following the web service tutorial from CN1 (https://www.codenameone.com/how-do-i---access-remote-webservices-perform-operations-on-the-server.html), I have my Codename one project as client and a dynamic web project running on my Eclipse tomcat server hosting the servlet.
As I have objects that I pass back and forth between client and server, I want both projects to know about these java files. The way to do that is to put the file in one project, and modify the build path of the other to include the first project. This way, the import can resolve the file name just fine.
Question now is: is it better to put the files in one project or the other? Does either way affect the size of the resulting app file that I want to publish in a store? I want to keep the size as small as possible.
Thanks for any tips.
UPDATE: on the preliminary information provided by Shai, files that are to be shared among different projects (either client or server side), do not put your code in either but INSTEAD create a CN1 library for that. This library can then be added to the CN1 buildpath configuration (not the Java build path!) to all required projects.
Here are the details on how and why: https://www.codenameone.com/blog/new-preliminary-library-support.html
Just need to figure out how to do this on Eclipse, as it does not seem to be supported now.
You can use shared code with a cn1lib whose source you can include into the server project manually. In some cases we just copy the shared source files in the build script from one project to the other as it makes the process simpler.
I'm facing a problem when I deploy a DTSX File to a production server.
In the DTSX file I consume a WebService through the Web Service Task,
The WebService asks for a WSDL File that it has to download from a local path.
There is no problem in my machine, but in the production server it won't ever exists.
I think it is not acceptable to ask to my client to get me permissions to enter in his production server and create a folder to store that wsdl file. In addition what will happen when the wsdl changes? I will have to deploy my dtsx package again and also replace the wsdl file in the server. So I think it is not an option.
So, my question is,
Is there a possible way to avoid to have a physical file with the wsdl especifcation, or it could be deployed within the dtsx deployment package, or save it in a variable, or how else I could do that?
I've been searching a lot, but still not luck.
Any help would be really appreciated.
To achieve this, one option would be to make use of Script Task and with the help of .NET namespace System.Net.WebClient, you can access the WSDL URL path and download the contents of the WSDL file to the system's temporary folder path. You can get the system's temporary folder path, which is the value of the environment variable TEMP, using the .NET method System.IO.Path.GetTempPath(). The newly generated temporary path of the WSDL file can be then stored in an SSIS package variable, which can then be configured in the Web Service Task for it to use instead of relying on a local path. Initially, during development you will need to have the WSDL file in the local path but once you deploy the package to the production, the WSDL file need not exist on the local drive.
Hope that helps.
I have written a WCF web service in C#. I had originally self-hosted it and then decided to host it on IIS running locally on my PC. While the service is working, there are several aspects of the deployment process that I don't understand:
Firstly, the URL of this service when hosted in IIS does not correspond to what I specified in my web.config. I had specified "http://localhost:8000/MyServices/OrderService" there and this was used when I self-hosted. Now that I've deployed to IIS, the URL has become "http://localhost/MyServices/OrderService". Why is the URL not picked up from my config file?
Secondly, to host the Web Service, I created a new web site within IIS (in addition to the existing 'Default Web Site'). I set the physical path to c:\inetpub\wwwroot (no idea if this is correct) and left the other parameters as default. I then copied my /bin folder, my .svc file and my web.config to this folder. Is this the equivalent of a 'Virtual Directory'?
Finally, the service didn't work until (within IIS) I selected 'Convert to application'. Why is it necessary to select 'Convert to application'?
Can anyone explain what the correct procedure is to publish a simple web service from Visual Studio into IIS, or point me at some good documentation so I can understand the process?
****EDIT TO ORIGINAL*****
Having spent more time looking into this, I have found the following:
When I create a web site in IIS, I give it a physical directory of c:\inetpub\wwwroot....etc
If I then "publish" from within Visual studio, all it's doing is copying all the required filed (like the /bin directory, web.config and .svc file) into the physical directory of the website i.e. - c:\inetpub\wwwroot...
You can perform the copy manually to the same affect.
Lastly, with regard to the URL of my service not corresponding to the baseAddress section of my web.config file, this has been answered on stackoverflow previously.
The answer is that the baseAddress is completely ignored when hosting on IIS.
If using Visual Studio 2010 you can right-click on the project for the service, and select properties. Then select the Web tab. Under the Servers section you can configure the URL. There is also a button to create the virtual directory.
I'd like to have my Axis2 Web Service read from a configuration file, whose name is sent as a parameter to the service.
Where is the best place to put this file? And How to best access it? Examples welcome.
I've checked the current directory is the Apache/Tomcat/bin file, I could put it in the parent directory, or put it into a Apache/Tomcat/conf, although this looks like it's more reserved for apache configuration itself.
You don't want to load a configuration file on each request, which means configuration needs to be loaded ideally on startup.
In my experience that leaves you with two choices:
Embedded Spring container
JNDI
The former approach is described in the Axis2 documentation, the latter approach depends on the appserver/container you're using.
An example if JNDI configuration for jetty is here: