[Contract First SOAP web service]: How to create WSDL? [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
My aim is to develop a SOAP web service in Java.
I want to go with the 'contract first approach'.
The obvious steps (in order) are:
Create a WSDL file from scratch
Generate Java classes using wsdl2java
Develop business logic round the generated Java classes
However, I am a little apprehensive about writing a WSDL from scratch (given the complexity).
I just wanted to know if there are any standard tools which are used to author a WSDL file from scratch?

Searching around the web, I realized that you have learn how to author WSDL yourself.
There are no wizard like tools that ask you few simple questions and do it for you.
WSDL is yet another XML schema definition (aka XSD) which defines the web service.
So using any standard IDE like IntelliJ IDEA, Eclipse, NetBeans should do the trick.
If you are apprehensive about authoring the WSDL, it may be because you are not comfortable with the following concepts (as in my case). So pull up your socks and spend some time to understand the following:
XML
XML Namespaces
XML Schema (XSD)
Here are a few resources that may help you write your own WSDL from scratch:
XML Schema : http://www.w3schools.com/schema/
XML Namespaces : http://www.w3schools.com/xml/xml_namespaces.asp
WSDL Structure: http://www.w3schools.com/xml/xml_wsdl.asp

Doing the same search around the web I managed to find only one free tool which may help writing WSDL.
WSDL Editor Plugin for Eclipse
This plugin is part of Eclipse Web Tools Platform Project and gives you full visual support when building WSDL document.

you can also start these process to generate WSDL.
1.) write java class. like
package test.web.service;
import javax.jws.WebMethod;
import javax.jws.WebService;
#WebService
public class WebServiceServer {
#WebMethod
public int addition(int a,int b){
return a+b;
}
}
providing a link : where you can learn soap web servive easily in effective manner
http://javabrains.koushik.org/p/java-ee.html

Related

Using java to generate WSDL with given parameters

I am looking for some tutorials or resources that may assist me with a problem in Web Service Composition, where I need to a generate WSDL with given inputs and parameters. I want to start from scratch like java with some "element" method that can output a basic WSDL hierarchy. Thank you.
P.S. I did spend a reasonable amount of time looking for above-mentioned stuff but I do consider the probability of encountering an open source implementation from this community.
Have a look at the tools provided in the Apache CXF project, which allows generating WSDL from Java source and vice versa. Similar functionality is provided by Apache Axis2.

Programmatic access to Java documentation [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Is there an api to programmatically access to the Java documentation? Something similar to what editors/IDEs like Eclipse do for IntelliSense. Surely, the javadoc generated html can be parsed and indexed, but would be great to know if something already exists as a standalone package.
Update:
To be clear, I am trying to get a programmatic access to the documentation for the java language implementation. However, there isn't an easy way out, but you have to get the openjdk from Oracle's site and then do make docs and supply some doclet to get the output in non-html form. This is what I was trying to avoid from the beginning. So I'm reading all the Makefiles now trying to figure out why $PLATFORM isn't being resolved and source build is failing!
What I finally settled with:
Scraping html docs. Yep. Realized that'd get my job done.
import urllib2
import pymongo
mongo = pymongo.Connection('localhost')
mongo_db = mongo['api_db']
mongo_collection = mongo_db['api_collection']
URL='''http://docs.oracle.com/javase/6/docs/api/index-files/index-'''
URL_range = 27+1
def getPageElements(url):
content=urllib2.urlopen(url).read()
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(content)
elements = soup('dl')
return elements
def savePageElements(elements):
for i in elements[0]:
try:
entry={'type_description':str(i.findNext('dt')).split('-')[1].split('<')[0]\
+i.findNext('a').findNext('a').renderContents(),\
'signature':i.findNext('a').findNext('a').renderContents()+i.findNext('b').renderContents(),\
'description': i.findNext('dd').renderContents()\
}
print entry
insert_id = mongo_collection.save(entry)
except:
pass
def retrieve(str):
mongo_documents = mongo_collection.find({
'signature': str,
#'type_description':"Method of java.io.PrintStream"
})
for this_document in mongo_documents:
print this_document
if __name__=="__main__":
for i in range(1,URL_range):
#url=URL+str(i)+".html"
#print "Processing:", url
#elements=getPageElements(url)
#print elements[0]
#savePageElements(elements)
retrieve("println(String)")
But take a look at dexy. If I could have managed to build OpenJDK on Ubuntu without issue - it would have generated nice JSON to play with.
As you write Eclipse does parse javadoc and does pretty good job of it. It seems it was introduced in 3.2M4. You may be able to extract the functionality from Eclipse sources, checking with Eclipse community for entry point may be a good place to start.
If that does not work, I guess your starting point would be a plain vanilla HTML parser.
The javadoc tool parses the information out of your Java files and delegates to a doclet to translate this structured information into documentation. The standard doclet produces the familiar HTML output but you can write your own and tell javadoc to use that instead. This is probably the most robust option if you have the original source code available.
You can use the output of the JavaDoc tool and parse it as XML as in this example.
You can also use other documentation extraction tools like Doxygen and parse their (better) XML output.
When you have basic parser knowledge, You can write a JavaDoc-extractor by your own. There are a lot of free Java parsers that are a good starting point. (I think this will be the best way for your research prototype).

Is there any Java Library to operate on unix config files like http.conf [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
There are very good Perl libraries (e.g. Apache::Admin::Config) to operate on traditional unix config files like httpd.conf. Anyone know if there is good Java libraries to do the similar task?
I know there is a c library called Augeas with Java binding. Has anyone used that before?
Thanks!
I worked (programatically, for a project) with a lot of config files from many *nix projects like Apache's, Squid's, smtpd's, ldap's, PAM's etc. etc. I have come to realise there is deffinetly NOT a common format (grammar) but instead each project defines his own ad-hoc format and implements it's own custom parser. No common specification.
So the aproach on *nix projects config files si not "use the parser library" but rather "write your own parser".
There are however projects that try to stick to some sort of standard. Most common amog theese is the .ini file format (originated on OS/2 and windows) or GConf file format, for theese you may find readily available parsers.
Apache (read a-patch-e, as in made from many patches) is in the free-form class. It started with a var value format then, after a lot of "patching", added a warty-xmlish grammar for specifing scope and context of config vars.
If you just tweak parts of the config file, probably your best approach would be to scan the file looking for your desired config vars and then work with the file locally.
If however you need to config the whole file, better make a Java parser based on the C one.
Here is a Java library that I developed for my own purposes.
https://github.com/kkapelon/Apache-Httpd-conf-Reader
It is very early alpha. Use at your own risk. Any feedback would be appreciated.
Here is a Java library that can be used to parse the Apache Server configuration. ApacheConfParser
There does not seem to be an existing library for that purpose. You could, however, use Augeas, a library made for editing configuration files. Unlike the solution you are searching for, however, you need to tell Augeas how to interpret the configuration file beforehand, which might take more time than it's worth.
Augeas has Java bindings indeed, and it has an Httpd lens, too, so it is definitely an acceptable solution.
Commons Configuration do manipulate configuration files.
Even it gives an option to save the manipulated properties in a new file also.
PropertiesConfiguration config = new PropertiesConfiguration("usergui.properties");
config.setProperty("colors.background", "#000000);
config.save("usergui.backup.properties);
Refer following link
http://commons.apache.org/configuration/userguide/howto_filebased.html#File-based_Configurations
Even, Apache Ant can also help you in manipulating the existing configuration files using your own PropertyHelper Implementation.
http://ant.apache.org/manual/properties.html#propertyHelper
EDITED after response in comments
Apache configuration do provide extensibility using bean Factory , you need to create the Apache config file httpd.conf domain class yourself , to make it working.
Defining the Apache modules in java you can have a look at Netloony source , service/apache/modules to have an idea on this.
http://netloony.sourceforge.net/userguide/intro.html
In netloony the config files values are presented in JTable, you need to use any configuration framework to persist it in file.
Hope this helps, I understand there is nothing out of Box in java presently to read apache conf files. I was trying to give a pointer where you can start with..

Easiest frameworks to implement Java REST web services [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
What are the best frameworks for implementing both client and server REST frameworks in Java? I've been struggling a little to find an easy to use solution.
Update: Both Jersey and Restlet seem like good options. We'll probably use Restlet but we'll experiment with both.
Jersey is really easy for both. To write web services, you use annotations:
#Path("/helloworld")
public class HelloWorldResource {
// The Java method will process HTTP GET requests
#GET
// The Java method will produce content identified by the MIME Media
// type "text/plain"
#Produces("text/plain")
public String helloWorld() {
// Return some cliched textual content
return "Hello World";
}
}
For a client:
Client client = Client.create();
WebResource webResource = client.resource("http://localhost:8080/helloworld");
String s = webResource.get(String.class);
System.out.println(s); // prints Hello World
Restlet sounds like it should provide what you're looking for:
Support for client and server (in a relatively symmetric api)
Smart url binding
mime type understanding (given accepted mime types, it will ask your resources for their representation in that type)
Supports JAX-RS annotations (just like Jersey)
Take a look at dropwizard too.
Restlet also support annotations in its 2.0 version, both on the client and server-side. The JAX-RS API is also supported as an extension.
Here is a simple example for server-side:
public class HelloWorldResource extends ServerResource {
#Get
public String represent() {
return "hello, world";
}
}
On the client-side:
// Outputting the content of a Web page
new ClientResource("http://www.restlet.org").get().write(System.out);
For further documentation, check this page.
There's JBoss' new RESTEasy library. It appears to be under rapid development since its initial launch. I've no idea if it's any good; it's on my 'check it out' list.
I haven't used it personally but some teams that I work with are using Spring 3 MVC. REST in Spring 3: #MVC looks like a good blog post overview. The RESTful features include "URI Templates", "Content Negotiation", "HTTP Method Conversion", "ETag support" and more.
Edit: Also, see this question: Can anyone recommend a Java web framework that is based on MVC and supports REST ?
You could take a look at the CXF JAX-RS implementation. For complete list of its features check the CXF web site for JAX-RS.
The community behind the project seems to be very active (July 2013). An indication of that is the number of messages per day in the CXF mailing lists.
I can recommend Apache wink, a new framework still in incubation mode, but very mature and high quality.
http://incubator.apache.org/wink/
It implements the JAX-RS specification, it has both client & server framework for REST development.
Apache is standing behind this project - that's always a good sign (and a good license :-) )
What I love most about this framework is the intuitive integration with Spring, it's very useful if you want your framework to be easily configured and extended.
UPDATE: Xydra Restless is not longer maintained +++ If your are using Goolge AppEngine before they release a "reserve instance" feature, you might consider Xydra Restless which has few features but loads fast.
My favourite is Spring MVC, you have support for both, client and server side... And you have Android support too =)
For example, you can see a example of Spring Android here

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