Remove duplicate jars
Simple MongoDB+Java example
Lightweight JSP development environments
jEdit with jGoodies
Jython is great
« Birthday Bash
» JDeveloper 10g - lighter!
If you go for a Visual Studio.NET demo, chances are that the speaker will try to impress you with its prowess when it comes to building web services clients (also called as consumers). Once you are impressed, the next slide will most certainly be about lack of such tools in the Java world. To a certain extent that is true, but in the context of web service consumers, Oracle JDeveloper is just as easy as VS.NET.
This is a small write-up that is aimed at helping you to like JDeveloper, by writing a client for Google web services. Once you have the software installed, you can see that it wouldn’t even take 5 minutes to have a working client.
File->New->General->Application WorkspaceName it as
WebServices
.WebServices
- you created, under it.WebServices
to create a new project called google
.main
method. Normally, you shouldn’t do this, but it keeps things simplified for this exercise.GoogleSearchServiceStub.java
- this is the proxy client that interacts with Google’s services.DirectoryCategory.java
- a class that implements a Google data type.GoogleSearchResult.java
- a class that implements Google search result data type; containing a list of ResultElement
s. ResultElement.java
- a class that implements a single Google search result element.GoogleSearchServiceStub.java
main
, you will see a line called //Add your code here.System.out.println(stub.doSpellingSuggestion(your_google_key_here, "mircosotf dot nut"));
Viola! There is your simple Google client in no time. Let us try to make this better.
My personal preference is never to edit the generated stub. Generally, I avoid modifying generated code. This makes it much easier to work on the code you need to write, without worrying about auto-generated code.
If you examine the stub code, you will see that all calls to Google (doSpellingSuggestion
, doGetCachedPage
and
doGoogleSearch
) have your Google key as the first argument. Here’s my suggested improvement:
Consumer
that extends GoogleSearchServiceStub.Consumer.key
to stores your Google key.Consumer
, call super()
first, and then initialize the key.
public String doSpellingSuggestion(String s) throws exception {
return super.doSpellingSuggestion(this.key, s);
}
If you prefer, download this zip archive that has my project files - remember to use your own Google key
in Consumer.java
and to set JDeveloper home in build.xml
!
Still better would be to define Google key in a properties file. I’m leaving that as an exercise.
JDeveloper is fine, you might want to build the code using Ant. Before you start making an
Ant file, right-click on project google and:
New->Ant file-> From existing project file
The default build.xml
created by JDeveloper shows that the CLASSPATH is quite large. Nevertheless, if you plan
to indulge in Web Services development, many of these packages are what you will need for every project. Perhaps, it is not
that much of a pain then!
Note: I realize screenshots would’ve made these notes easier to read ;-)
Update 10/27/2003: A good month after this blog entry was published, Oracle has authored their own how to develop Google consumer using jDeveloper 10g That is presented as an article, with screenshots - they use Google services to make their own JSP client.
Thanks for the notes.. will surely come in handy when I jump on the webservices bandwagon.
Hi ,
I am getting the following error.
Any Proxy settings or bypass proxy code will do...
[SOAPException: faultCode=SOAP-ENV:Protocol; msg=Unsupported response content type "text/html", must be: "text/xml". Response was:
<HTML>
<HEAD><TITLE>Firewall Error: Forbidden</TITLE></HEAD>
<BODY>
<H1>Forbidden</H1>
You are not permitted to access the remote system.
<p>
If this is an error, then you should contact your local firewall
administrator.
</body></HTML>
]
at org.apache.soap.rpc.Call.getEnvelopeString(Call.java:209)
at org.apache.soap.rpc.Call.invoke(Call.java:268)
at webservices.GoogleSearchServiceStub.doSpellingSuggestion(GoogleSearchServiceStub.java:74)
at webservices.GoogleSearchServiceStub.main(GoogleSearchServiceStub.java:43)
Please refer Jdeveloper help:
Search in help for:
"When the Proxy Server Requires Authentication"
---------
Do the following:
(in Jdeveloper 10g)
When you create the stub in wizard check the "Generate Basic Proxy Authentication Code"
---
It generates the following part of the code:
Properties props = new Properties();
props.put(OracleSOAPHTTPConnection.PROXY_AUTH_TYPE, "basic");
props.put(OracleSOAPHTTPConnection.PROXY_USERNAME, "proxy_username");
props.put(OracleSOAPHTTPConnection.PROXY_PASSWORD, "proxy_password");
props.put(OracleSOAPHTTPConnection.PROXY_HOST, "194.128.210.21");
props.put(OracleSOAPHTTPConnection.PROXY_PORT, "80");
m_httpConnection.setProperties(props);
Change your proxy_username and proxy_password.
-----------
(My company uses the windows network username and password for proxy authentication.)
Kind regards
Otto
Even by adding authentication, I am getting the below error...
[SOAPException: faultCode=SOAP-ENV:IOException; msg=ModuleException thrown by HTTPClient while getting the response.HTTPClient.AuthSchemeNotImplException: Negotiate; targetException=java.io.IOException: ModuleException thrown by HTTPClient while getting the response.HTTPClient.AuthSchemeNotImplException: Negotiate]
at oracle.soap.transport.http.OracleSOAPHTTPConnection.send(OracleSOAPHTTPConnection.java:765)
at org.apache.soap.rpc.Call.invoke(Call.java:261)
at mypackage1.SMSStub.SSG_IVR_CheckDEL(SMSStub.java:111)
at mypackage1.SSGClient.main(SSGClient.java:14)
Sres. Oracle:
SOlicito muy comedidamente, me ayuden con el siguiente error:
invalid request URI '/soap/servlet/soaprouter'
i have this error whenever i try to test my webservice in jdeveloper, any one knows?
[SOAPException: faultCode=SOAP-ENV:Protocol; msg=Unsupported response content type "text/html", must be: "text/xml". Response was:
NOT FOUND
Hi,
When calling a web service from an applet, i get this exception:
java.lang.ExceptionInInitializerError: java.security.AccessControlException: access denied (java.util.PropertyPermission * read,write)
when trying to execute 'm_httpConnection = new OracleSOAPHTTPConnection();' in the stub...
I don't think there is any security constraint about that...
What may be the reason?
Hi
I am getting this exception when trying to using webservices from java client
however if i use lan connection i am not getting this exception.I am getting this exception at the time of dial up only.
Please help me
Manish Poddar
[SOAPException: faultCode=SOAP-ENV:IOException; msg=Connection timed out: connect; targetException=java.net.ConnectException: Connection timed out: connect]
at org.apache.soap.SOAPException.(SOAPException.java:78)
at oracle.soap.transport.http.OracleSOAPHTTPConnection.send(OracleSOAPHTTPConnection.java:765)
at org.apache.soap.rpc.Call.invoke(Call.java:261)
Estoy consumiendo un webservice desde Jdeveloper y me presenta el siguiente error, alguien tiene idea de que pueda ser???????
[SOAPException: faultCode=SOAP-ENV:Client; msg=No Deserializer found to deserialize a ':DatosSalida' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.; targetException=java.lang.IllegalArgumentException: No Deserializer found to deserialize a ':DatosSalida' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.]
Gracias