•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the RSS, Web Services and SOAP section within the Web Development category of DaniWeb, a massive community of 375,194 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,174 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our RSS, Web Services and SOAP advertiser:
Views: 1521 | Replies: 7 | Solved
![]() |
•
•
Join Date: Aug 2006
Location: South Africa, Durban
Posts: 99
Reputation:
Rep Power: 2
Solved Threads: 8
Hey guys, I'm really new to this
I've managed to setup a Web Service and a Client to access the service within Eclipse. However, I want to access a Web Service that already exists. From what I understand, that service must have a WSDL (Web Services Description Language) for it to be used by Eclipse. The Web Service that I want to interact with does not have a WSDL or at the very least it doesn't have a .wsdl file. Um I'm hoping that's possible or perhaps I've confused the application I'm trying to access for a Web Service?
I'm using a pre-defined platform that can process SOAP requests. Just to confirm the following is a SOAP request hey?
I want to be able to send requests via a Java program and interpret these results within the program. Can anyone please tell me how this is done? I'd need the appropriate .jar files hey? I'm not sure what they are or if they even come with Eclipse. The version of Eclipse that I have is the JaveEE one. Please advise
I'm using a pre-defined platform that can process SOAP requests. Just to confirm the following is a SOAP request hey?
xml Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8"?> <GetObservation service="SOS" version="0.0.31" xmlns="http://www.opengeospatial.net/sos" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:ows="http://www.opengeospatial.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:swe="http://www.opengis.net/swe"> <offering>TAG_READING</offering> <eventTime> <ogc:During> <gml:TimePeriod> <gml:beginPosition>2007-12-10T08:00:00</gml:beginPosition> <gml:endPosition>2007-12-13T12:00:00</gml:endPosition> </gml:TimePeriod> </ogc:During> </eventTime> <procedure>urn:ogc:def:procedure:wavertrend_rx201_sensory_web</procedure> <observedProperty>urn:ogc:def:phenomenon:OGC:1.0.30:temperature</observedProperty> <featureOfInterest> <ObjectID>COR01</ObjectID> </featureOfInterest> <resultFormat>text/xml;subtype="OM"</resultFormat> </GetObservation>
I want to be able to send requests via a Java program and interpret these results within the program. Can anyone please tell me how this is done? I'd need the appropriate .jar files hey? I'm not sure what they are or if they even come with Eclipse. The version of Eclipse that I have is the JaveEE one. Please advise
•
•
Join Date: Aug 2006
Location: South Africa, Durban
Posts: 99
Reputation:
Rep Power: 2
Solved Threads: 8
I think that a Web Service offers remote procedure calls (methods that can be called over the internet). The application I'm working with is really a servlet that accepts xml requests so I guess it isn't a web service? I'm a bit unsure as to how I would perform such the xml request in Java though. I think that I'd need to create a URL object that points to the actual servlet?
I'm not really sure what other parameters are used in setRequestProperty but can I simply create an output stream and write the xml request to it?
It doesn't seem to be working out, can someone please advise?
java Syntax (Toggle Plain Text)
URL service = new URL("http://localhost:8080/52nSOSv2/sos"); URLConnection connection = service.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setUseCaches(false); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
java Syntax (Toggle Plain Text)
ObjectOutputStream out = new ObjectOutputStream(connection.getOutputStream()); String request = ""; //xml request with correct escape sequences out.writeChars(request);
•
•
Join Date: Nov 2007
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 1
hi,
web service soap interface is defined by a wsdl file.
you can manually write a wsdl file or you can use some tools to generate the same(preferred way).
now, this wsdl file will work as a contract between soap server and soap client .
both server and the client can use this file to generate the stub files wrt soap methods.
I m not sure whether u was asking the same or you have some other doubt!!
Have fun with it!!
Manoj
web service soap interface is defined by a wsdl file.
you can manually write a wsdl file or you can use some tools to generate the same(preferred way).
now, this wsdl file will work as a contract between soap server and soap client .
both server and the client can use this file to generate the stub files wrt soap methods.
I m not sure whether u was asking the same or you have some other doubt!!
Have fun with it!!
Manoj
•
•
Join Date: Aug 2006
Location: South Africa, Durban
Posts: 99
Reputation:
Rep Power: 2
Solved Threads: 8
Thanks for replying! So I should find a .wsdl file somewhere within the application if I was indeed working with a web service? Then I most definitely do not have a Web Service. That's one doubt cleared up thank you!
Now I'm not sure how to interact with the serlvet. The Java program I'm writing must be able to send requests in the form of xml to the servlet and get the response back. Hmmm this sounds like something for the JSP forum. I've been reading up on servlets bust still can't get it right. The error looks something like this: An xml error occurred when parsing the request: XML Exception: error: Illegal XML character: 0x0
Now I'm not sure how to interact with the serlvet. The Java program I'm writing must be able to send requests in the form of xml to the servlet and get the response back. Hmmm this sounds like something for the JSP forum. I've been reading up on servlets bust still can't get it right. The error looks something like this: An xml error occurred when parsing the request: XML Exception: error: Illegal XML character: 0x0
•
•
Join Date: Nov 2007
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 1
hi,
for a web service method....input and output parameters should be an xml document.
let me tell me the basic logic.........
wsdl file is nothing but is an interface(just like some other java interface) and you should have some .java file which is implementing this interface.
wsdl file contains the information about the name of the methods, input/output parameters , message format, binding information, url's etc....,
so just like any other class what you have to do is to get the access of wsdl file(soap interface) from some other code(servlet/c# code/c++ code) and call the respective interface - as simple as that....
i dont have much idea in servlets...but if u want i can tell u with example how to access the same from c# code.
Have fun with it!!
Manoj
for a web service method....input and output parameters should be an xml document.
let me tell me the basic logic.........
wsdl file is nothing but is an interface(just like some other java interface) and you should have some .java file which is implementing this interface.
wsdl file contains the information about the name of the methods, input/output parameters , message format, binding information, url's etc....,
so just like any other class what you have to do is to get the access of wsdl file(soap interface) from some other code(servlet/c# code/c++ code) and call the respective interface - as simple as that....
i dont have much idea in servlets...but if u want i can tell u with example how to access the same from c# code.
Have fun with it!!
Manoj
•
•
Join Date: Aug 2006
Location: South Africa, Durban
Posts: 99
Reputation:
Rep Power: 2
Solved Threads: 8
I understand that the wsdl file is written in xml and describes what remote methods (which could be regarded as services) are accessible and what their parameters are. I noticed that in Eclipse one can import a war file. I've done that and it Eclipse automatically generates the wsdl file. However, the import process isn't totally successful and the project itself has alota xml errors; errors that I'm not sure how to resolve. What I don't understand is that the wsdl file describes access to the servlet. A servlet has methods that are automatically invoked whenever access to a servlet is invoked. So instead of actually using SOAP, one would be able to simply POST to a serlvet. But I suppose being able to POST using SOAP could be useful in my application. Regardless, I still can't seem to get the project up so I can't test it. Thank you for your help Manoj! I wish I could just POST to the servlet as if I was using a HTML form but within a standard Java Application.
•
•
Join Date: Aug 2006
Location: South Africa, Durban
Posts: 99
Reputation:
Rep Power: 2
Solved Threads: 8
JSP is really a cool extension of HTML. I think the most common way to interact with a servlet via a JSP is to use the HTML <form> tag. I have managed to successfully create a connection to the servlet via a standard Java application. The thing I completely overlooked was that the xml request that I was sending had to be sent in URL encoding. If anyone’s interested, this is who I've done it:
This site was rather useful: http://www.javaworld.com/javaworld/j...javatip34.html
The guy there said that the HTTP request's "content-type" field to be "application/x-www-form-urlencoded" because it is necessary since some versions of Netscape's browser has a bug which does not give out this proper content type when doing POSTs.
I think it would have been better if I just read in the xml request from a file - that's what I think I'll try to do now
Oh and the URL: http://localhost:8080/52nSOSv2/sos specifies the URL to the servlet as defined in the web.xml of any servlet driven website.
java Syntax (Toggle Plain Text)
URL service = new URL("http://localhost:8080/52nSOSv2/sos"); URLConnection connection = service.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setUseCaches(false); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); DataOutputStream out = new DataOutputStream(connection.getOutputStream()); String request = URLEncoder.encode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<GetObservation service=\"SOS\" version=\"0.0.31\" " + "xmlns=\"http://www.opengeospatial.net/sos\" " + "xmlns:gml=\"http://www.opengis.net/gml\" " + "xmlns:ogc=\"http://www.opengis.net/ogc\" " + "xmlns:ows=\"http://www.opengeospatial.net/ows\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xmlns:swe=\"http://www.opengis.net/swe\">" + "<offering>TAG_READING</offering>" + "<eventTime>" + "<ogc:During>" + "<gml:TimePeriod>" + "<gml:beginPosition>2001-12-10T08:00:00</gml:beginPosition>" + "<gml:endPosition>2008-12-13T12:00:00</gml:endPosition>" + "</gml:TimePeriod>" + "</ogc:During>" + "</eventTime>" + "<procedure>urn:ogc:def:procedure:wavertrend_rx201_sensory_web</procedure>" + "<observedProperty>urn:ogc:def:phenomenon:OGC:1.0.30:temperature</observedProperty>" + "<featureOfInterest>" + "<ObjectID>COR01</ObjectID>" + "</featureOfInterest>" + "<resultFormat>text/xml;subtype=\"OM\"</resultFormat>" + "</GetObservation>", "UTF-8"); System.out.println(request); out.writeBytes(request); out.flush(); out.close(); DataInputStream in = new DataInputStream(connection.getInputStream()); String line = ""; System.out.println("Response!!"); while ((line = in.readLine()) != null) System.out.println(line);
This site was rather useful: http://www.javaworld.com/javaworld/j...javatip34.html
The guy there said that the HTTP request's "content-type" field to be "application/x-www-form-urlencoded" because it is necessary since some versions of Netscape's browser has a bug which does not give out this proper content type when doing POSTs.
I think it would have been better if I just read in the xml request from a file - that's what I think I'll try to do now
Last edited by PoovenM : Jan 9th, 2008 at 2:09 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb RSS, Web Services and SOAP Marketplace
•
•
•
•
advertising asp blog blogger browser browsers code community data design development domains feed firefox gdata google html intel internet java legal linux marketing microsoft mozilla multimedia news opera php privacy programming reader registration report research rss search security software sun video w3c weather web web development wiki xml xoap yahoo youtube
- Project Suggestions in Accessing Databse from a computer through sending SMS message (Computer Science and Software Design)
- ASP.Net Security 101 Part 1 (ASP.NET)
- Cannot open certain websites, including hotmail (Web Browsers)
- Asynchronous Web Services in .NET Using WSE 2.0 (ASP.NET)
- Web filter software (Networking Hardware Configuration)
- Fatal Error Message When Accessing A Web Page (Windows NT / 2000 / XP / 2003)
- Web Browsers cannot access internet, but Outlook/Messenger Will (Web Browsers)
- Wbe service accessing MySQL database (MySQL)
- cannot connect to a messenger service (Networking Hardware Configuration)
Other Threads in the RSS, Web Services and SOAP Forum
- Previous Thread: Output XML from a servlet
- Next Thread: View an xml file in ie


Linear Mode