Can I change the Java package of a WebService Client? - java

So, my JAVA application is connected to different WebServices that were developed inhouse and all 3 of them are packaged under org.tempuri
This is the default namespace I believe and when the wizard creates the Java packages it places them under org.tempuri..
I wanted to change them to give them meaningful names but then my app exploded :(
Can I just go into the .wsdl and change the namespace and repackage it all? Or some way that I can change package "org.tempuri" to "com.abc.ws.imageservices"
I would do a trial and error on my free time, but it would take me a couple of days since the job has other priorities..., so I'm hoping that an answer is faster.

You should look into wsimport.
Wsimport will allow you to import directly from a WSDL and one of the parameters in the output project.
wsimport -p com.abc.ws.imageservices -d src/ -wsdllocation http://my.wsdl.com/location?WSDL

If you're using RAD or WID, yes.. it can be done really fast if you refactor the namespace (which would change the WSDL) and then you just have to regen.

Related

How to create and use class instances in C# from JAR files?

I'm aware of all the other questions about this topic, but I haven't found a good solution for my problem. Currently I am trying to use Java code in my C# project. I've already tried to convert the JAR files into .DLL files with IKVM, but this didn't work for me because the JAR files are to complicated to translate into C# because not every component, which were used in Java, can be found in C#. The normal call of the JAR file doesn't work for me either because I need to work with the class instances of the declared classes in the Java code.
Back to my question: Does anybody know how I could use Java code in my project? I've heard that it may be possible to implement Java code like it would be native, is that true? Note that I've to work with the class instances of the classes declared in the Java code.
I highly appreciate any kind of help, sheers!
Edit:
My work around would be that I include batch files, which are calling the JAR files. I will include these batch files into my C# Project and work with the batch files. This may be a even better approach for me because every input and output of the JAR files are done via XML files.
This kind of mixup are not generally a good approach. I think the .Net Framework is very mature and you can find everything you want to do your work.
I would suggest you the following approach :
You can wrap your Java library in a REST API and call it in your C# code. Your REST API can be hosted on an external server or use an embedded server or even a spring boot project.
You can read this post for more details.

Swagger-codegen renames methods with same names

I have generate a swagger client api with:
java -jar swagger-codegen-2.2.3/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http://localhost:8080/myproject/services/service0/swagger.json -l java -o client/myproject/java
But swagger-codegen rename methods with same names despite the fact that they are in different java clases. Is there any option to solve that issue?
The renaming of method will not affect the URL path and you should be able to make the REST call with the generated UI .
Even i don't know the reason why Swagger code gen works that way .
But i also feel that our API consumers doesn't have to know the method which are called either . So generated UI should be good to go

Webservices :Understanding the task assigned

I am a complete newbie to web services and I am working alone. My lead mailed me a task to complete. I think he has hard coded the information and he wants me to replace the hard coded data from web services.
He has mailed me a WSDL file and said
Make the jar file from the wsdl.
What does this mean ?
There are tools which will generate Java code to talk to web services, performing serialization and deserialization effectively, so that your client code can talk in terms of Java objects rather than raw SOAP.
You should find out which of these tools is being used in your project, and apply it to the WSDL provided.
(Also, it's a good idea to get used to asking for more information when you don't understand the assignment. A good team leader - or anyone, really - should be more than happy to help you.)
Generate the Java stubs from the wsdl.
wsdl2Java
wsdl2Java
If you are familiar with eclipse, then the task can be completed easily. I think he is asking for the jar of client stub which can be produced from the wsdl.
In that case do: In eclipse, make sure you have webservices plugin. Follow this after that
You will have few .java files being exported. Try to compile them and generate the .class files. Now jar the .class files using command in command prompt
jar -cvf <Name of the jar>.jar *

Compiling CSS to SWF server side Java, What is the best practice?

My project allows users to create custom css for our flex app.
In regards to compiling the CSS into SWFs on the server side:
Should I use the flex2.compiler.css.Compiler class in mxmlc-3.5.0.12683.jar?
Or
Should I invoke mxmlc from Runtime.getRuntime().exec()?
The css.Compiler class is not very well documented. Does anyone have any examples that use this?
For the Runtime exec method, what is the best way to package mxmlc into the maven build so its available to the server at runtime?
I think it is so rare that people try to compile Flex Apps on the fly at the server, that there probably isn't a best practice. My intuition is that using the jar file makes more sense if your server side code is Java.
But, if documentation is a problem the Flex command line compiler arguments are well documented and may save you a lot of time.

How to create WSDL file given SOAP WSDL operations

I haven't had any experience with web service related development. So, any ideas will be greatly appreciated.
Suppose, I have a file listing draft specification of WSDL operations. Following is one example. How would I go about creating the WSDL file. Is notepad sufficient or do I need to have WSDL editor?
getHostSystemInfo
Returns detailed information about host systems specified via given IDs.
input HostSystemIdCollection(Collection of Strings)
Output HostSystemInfoCollection
HostSystemInfo
Id: mandatory
Properties: Following properties should be provided for host systems
HostSystemName
HostSystemProperty1
HostSystemProperty2
HostSystemProperty3
....
....
If the question is just "how do I create the WSDL" then you could indeed use Notepad and just write it, it's only XML after all. However, writing syntactically correct XML by hand is pretty dull, and error prone. So I would recommend using WSDL aware tooling for example an Eclipse editor
An alternative is to write some Java which expresses the interface, and from it generate the WSDL. There are many ways of doing this, including starting with an EJB and annotating it accordingly. A few googles should help you find what you need.
My experience is that simple POC situations tend to work well starting at the Java. Larger scale projects benfit from considered designs starting at the WSDL.
coding WSDL by hand is a big pain! i used a XML editor for creation of and then generated the stubs with JAXWS. It is important to understand and differences of the WSDL styles, which is not trivial (have a look at WSDL styles). a good help is to import the WSDL schema to your IDE (eclipse, idea) and then work with autocompletion.
just for interest, why are you using WSDL + SOAP. if you have a choice and you use anyway HTTP, have a look at REST. It can make implementation of web-api a LOT easier, both on server side and for api-clients.
If you haven't done any web services before, I would strongly recommend a WSDL Editor. The Netbeans has a plugin that should help.
The other way of doing it, which may be easier is by using the Java annotations defined in JSR 181.
Of course you could use the worst text editor in the world (!) but I'd seriously consider using any decent XML editor or IDE (Eclipse's WSDL support is pretty decent). This will save you a lot of pain and suffer.
Or, if this is an option, you could just annotate a Java class with JAX-WS annotations and have your WSDL dynamically generated from the Java code. Personally, I prefer the WSDL-first approach, the Java-first approach is just a suggestion to get you started.
You could use Axis2 to create that for you.

Categories