I've inherited the code base for a Java application which talks to a few SOAP web services. Proxy classes to do this are generated using an ANT task calling wsdl2java. As my Java experience is quite limited, I'm still trying to get my head around exactly how this all works.
There is a build-wsdl2java.xml file in the project that seems to contain the configuration information required for the class generation. The file as it stands currently has attributes that aren't currently supported (namespacesmapfile, overWriteTypes, testcaseoverwrite), but if I attempt to resolve this by changing the first to 'namespacemappingfile' and removing the others, the attributes revert back if the project is cleaned. The URL for the WSDL also reverts back if it is changed.
What controls the generation of this file, and where do I define the configuration parameters that it contains?
Finally found out what was controlling this and, more importantly, have got things compiling again. I'm using JBuilder 2008 (an Eclipse based Java IDE from Embarcadero Technologies), and it would appear the client proxy classes were generated from the WSDL by using JBuilders built in support for this, which is effectively a wrapper for wsdl2java as mentioned by Noergaarde.
In order to set settings such as the URL for the WSDL, I had to switch to the Modeling perspective, and use the Model Navigator to change the URL, by selecting the class under the Web Service Client node and using the Properties view.
When you do a build of your project, does the timestamp of build-wsdl2java.xml change? ie. is this file generated by the build in another ant file?
At any rate, it certainly sounds like your client stubs are generated using AXIS.
http://ws.apache.org/axis/java/user-guide.html#WSDL2JavaBuildingStubsSkeletonsAndDataTypesFromWSDL
Related
We have a SOAP axis2 server that we cannot control that exposes some webservices.
We created a webservice client using the wsdl from that webservice. It generated the java code from the wsdl using Eclipse
This will be deployed in production but if the server adds a outputfield for example, our code will break and we will need to generate the java code again, make a jar and deploy on the server.
This does not make any sense. It should be 100% or extremely close of update.
Does it make sense to generate the java code from the WSDL and xsd from the local files?
All the examples I saw were like this
you can configure your JAXB2-Deserializer to ignore unkown (optional) elements, that preserves a bit of compatibility. Or modify the generated xsd to allow additional elements (xs:any) on the desired level.
But yes, that's a problem mostly solved by management
Is there any way I can put jrxml files onto the Jasper server, link it to a datasource and let it compile without iReports, Java-Bridge, local Jaspersoft UI, ... I want to use as little Java as possible and I don't know about Apache ANT.
Can I do it through the (PHP) REST/SOAP API?
Or can I setup a little shell script on the Jasperserver that I can use like this way:
./compileMyReport.sh --report=/home/bla/test.jrxml --datasource=MongoDB_test_1
What do you mean by "Jasper server"? Do you mean the "JasperReports Server - Web Application" (http://community.jaspersoft.com/project/jasperreports-server)? If so, it does offer a REST interface. Have a look at the "JasperReports Server Web Service Guide" (http://community.jaspersoft.com/documentation?version=7114).
If you, however, only want to have reports somewhere and execute them programmatically that can also be arranged (and would be much easier than to go via the JasperServer Rest Interface). For this you would only need to set up a minimal java class. You could then simply call this "script" via a e.g. a system call and let it generate the report to disk. I've recently blogged about a security issue with jasperreports and there I'll also give the necessary code to execute jaspers: http://blog.datenwerke.net/2013/05/jasperreports-in-box-part-i.html
Hope that helps.
I started looking into MoDisco. So far I can discover a java model from an existing java project and write transformations using ATL to modify my java model. However I was unable to generate java code for that modified java model. In this demo there is java code generated from a modified model. An Acceleo launch configuration called JPAProject_Regeneration is used for that as can be seen in this screenshot:
Does anyone know how that launch configuration looks like? Is there a tutorial that explains the creation of this launch configuration?
The mentioned launch configuration can be found in the eclipse svn. However it isn't that helpful, because it heavily depends on a very specific local setup that includes hard coded absolute paths.
MoDisco also provides a discoverer in the plugin org.eclipse.gmt.modisco.java.generation. However this discoverer is registered under the wrong extension point and therefore unavailable from within the UI. See the filed bug.
Also note that once the discoverer is registered correctly it is only applicable if the java model is within a file ending with .javaxmi.
EDIT:
The whole plugin org.eclipse.gmt.modisco.java.generation seems deprecated, because there is a new API for discovery. I built a new plugin that does the same as the mentioned MoDisco plugin based on the new API.
I've seen this problem all over the Web, but still haven't found a clear solution that has worked for me. Here's the issue:
I am trying to create a Web service client in Java. The client needs to be a console app that will be placed on a server and automatically run at a certain time interval. The Web service I am trying to consume was written and is hosted by a third party company. The service was written in ASP.NET. The company in question has several services that we hit. All of them are written in ASP.NET. I have never dealt with these services until 2 days ago when I was tasked with consuming 2 of the services and building an Excel spreadsheet from the data. Before I continue, let me describe my development environment. Some of this is relevant, some is not, but I want to include everything:
Windows 7 Professional 32-bit
NetBeans IDE 6.9.1
Java JDK 1.6.0_17
jre6
Glassfish 3 Open Source Full-Platform Release
All software has had all available updates applied
On to the problem. When I added the first Web Service Client to my console app, I was surprised at how smoothly the process went. Most of my experience writing Web Service apps is in .NET. I was able to import the WSDL and NetBeans generated all classes on the first try. Within 5 minutes, I was able to make my first call to the service and was greeted with the expected response, letting me know that my attempt was successful. I then added the second Web Service Client to the console app using the address to the second WSDL I needed. This is where I ran into a major problem.
Upon importing the WSDL, I was alerted to an error by NetBeans stating:
Web Service Client can not be created by JAXWS:wsimport utility.
Reason: undefined element declaration 's:schema'
After abusing Google for the next hour looking for a solution, I finally decided to apply some trial and error. Looking at the Output window in NetBeans, I could see that it was complaining about 3 specific lines. Once I took a look at the WSDL, I could see that those 3 lines were exactly the same, as follows:
<s:element ref="s:schema" />
These 3 lines were found in random places from the top of the WSDL, down to about half-way through. I removed these lines from the WSDL found in the Web Service References folder, leaving the WSDL in the META-INF folder alone. I then did a refresh on the service reference and much to my surprise, NetBeans parsed the WSDL and generated my classes just as before. Great, right? Well, here's where problem #2 comes into play.
Now that I was able to compile my app with no errors, I had to try to hit the service to see if my hack had worked. It did not. Because of another bug in JAXWS, I have to provide the URL to the WSDL in the constructor when creating a service object. This means that the WSDL I fixed is being ignored and the service is now back to using the WSDL that can not be parsed. When I tried to provide the location of WSDL I edited locally within my project, I was greeted with another compilation error stating that I had a NullPointerException. It said that I needed to initialize the object before using it.
I have researched what seems like an infinite amount of topics on this site looking for and trying any solutions that have been provided. I have also tried solutions from all over the Web, all with no luck. If anyone has any advice for me, any tips, tricks, hacks, please let me know. I'm open to any suggestions at this point.
Thanks in advance for any assistance provided.
One-sided contract changes may lead to problems.
Assuming the s prefix refers to the http://www.w3.org/2001/XMLSchema namespace, it looks like your WSDL references XML schema types. JAX-WS is probably unable to resolve this when generating the JAXB bindings.
You can download the XSD from http://www.w3.org/2001/XMLSchema.html; at a minimum, you'll need XMLSchema.xsd, XMLSchema.dtd and datatypes.dtd. Generating Java types from this may require fiddling with your JAXB binding configuration.
Alternatively, it may be easier to just use dynamic JAX-WS client code. You can use a tool like soapUI to create/test sample XML requests.
If you do decide to edit the WSDL, the generated service code should have a constructor of the form Foo_Service(URL, QName) that allows you to provision the WSDL locally (e.g. from your classpath).
The first thing I'd do is try to open it in one of the tools meant for testing SOAP services, like SoapUI. If you have schema not resolving, that is possible there will be pieces of code that you may need that won't be generated as well. I had that happen recently with a vendor supplied "web service", and after much dissembling they "miraculously" found an alternative set of services that worked fine.
You could also try some of the alternatives to Jax-Ws, like CXF or Axis.
Seen that writing GWT code is basically writing Java code, what does a GWT for an IDE exactly do? For example there are GWT plugins for IDEA and for Eclipse (and maybe for NetBeans?) but do they do that I cannot do simply by using Eclipse or IDEA without the GWT plugin?
They add wizards, dialogs, editors, and other extensions to the IDE that help specifically with GWT tasks. For example, rather then creating a new GWT project from scratch using the command line, or creating an eclipse java project and then creating all the necessary files yourself, the plug-in adds a wizard that lets you type in the name of the project, and it creates all the necessary files for you.
Other additions can be large stuff like a local server, or minimal like a source code formatter. The sky is the limit with plug-ins.
I know the GWT adds a GUI editor to eclipse so you can drag and drop controls rather then manually entering them all.
I've only used the IDEA plugin myself. I definitely would not want to give it up. As others have said, you can create a GWT project and debug in hosted mode as easily as you would run any other application, but that's only the beginning.
IDEA also has several GWT-specific class creation options. You can create a new UiBinder file, which will generate both the .ui.xml file and the Java file, and will already have the plumbing in place for creating the UiBinder object. You can create a new GWT Remote Service, which will create the service interface, async interface, and implementation class for you.
The GWT plugin will also warn you about tons of probable errors right in the editor. It will warn you if your service interface doesn't have proper matching methods in the async interface, and has an intention for fixing the problem. It will warn if your service implementation class does not have an entry defined in the web.xml file (yep, with an intention available to automatically register it). It will warn you if you have fields in your UiBinder class that aren't defined in the .ui.xml file, again with an intention to help resolve the issue with just a couple keystrokes.
On top of that, the code completion is excellent for everything including CSS attributes, Javascript, HTML, and the various XML files.
Yes, you can, however using a plugin for a given IDE, helps you by not needing to swap from the IDE to another tool ( for testing for instance )
Here's the demo of IDEA
http://www.jetbrains.com/idea/training/demos/GWT.html
The same way you can also compile from the command line ( I do it sometimes ) or let the IDE help you by pressing a single button.
Doesn't the GWT Eclipse plugin provide the debugging capabilities? GWT debugging in eclipse is the most useful tool ever.
There also is a plug-in for MyEclipse that gives you a Matisse-like drag and drop Toolbox for GWT.
For Netbeans we have the GWT4NB plug-in, which offers among other things good debugging and code completion which works also for .ui.xml files.
OK ...
GWT RPC - With Google plugin, it does reduce the tedium verifying the interface RPC interface-async pair declaration.
UiBinder. Each uibinder set is a pair of files: The ui template and the template bean. The plugin helps me verify the correspondence of uifields in the template and the template bean. Then there are #uifactory, #uifield(provided=true).
You can declare another an "external" bean (a java code other than its template bean) using ui:with in the ui template. With that you pull in functions from the bean to provide values for your gwt widget attributes. The plugin provides me with auto-complete/verification of functions that are visible in ui:with bean.
Of course, the plugin provides the compiler too, which compiles the java code into javascript.
The debugger which works with the client-side. Imagine how the plugin works when we step the debugger on the client code which is compiled to javascript.
The run config, which automatically fills in the blanks, the args and params. I would hate writing a gwt launch config by myself.
Without the plugin, GWT development would be rather tedious.