How can i access a webservices can any one send me a example i have URL "http://wsdds2.dz.decarta.com/openls/openls" which will accepts only xml formate and wich will recive xml formate can any one help on this. as soon as possible
Thanks & Regards,<br />Prasanth Duggirala.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35254
7
posted
0
Do you mean it receives SOAP requests, or just that it receives POST requests containing XML and that it returns XML? If the latter, you should be able to use the java.net.HttpUrlConnection class, an example of which can be found at http://www.exampledepot.com/egs/java.net/Post.html
I want to access a web service and pass a request as a string and get the responce as a string.
can any one provide any example.
and then i want to convert the java class in web services file.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35254
7
posted
0
I want to access a web service
What kind of web service is this - SOAP? REST? Something else? What are its inputs and outputs?
i want to convert the java class in web services file.
I don't understand this. What is "the Java class"? What is a "web service file"?
Prasanth Duggirala
Ranch Hand
Joined: Dec 22, 2006
Posts: 36
posted
0
www.deCarta.com The DDS Web Services provides an XML-over-HTTP service interface. The service accepts XML for Location Services (XLS) requests and returns XLS. The response from the DDS Web Services contains URLs for images, and XML elements representing addresses, routes, points of interest, and other structured information needed by a geospatial developer.
What I need to know? Whether we can create a web service, which will be a middle tire which will have all functionality in the web service . The inputs are xls out put is also xls. How can we interact with web services.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35254
7
posted
0
I don't know what DDS is or does, but from what you describe it sounds more like it's not SOAP-based. So you'd probably be sending and receiving XML over an HTTP connection directly, much like the example I linked to above. I'm sure their site has information on how exactly to connect to it.
You'll probably want to use an API for creating and reading the XML; I've used XOM for that in the past. [ November 07, 2008: Message edited by: Ulf Dittmer ]
Prasanth Duggirala
Ranch Hand
Joined: Dec 22, 2006
Posts: 36
posted
0
hi
This the method i am taling about i got in deCarta site only,
//show what gets sent to server marshaller.marshal( msg, System.out );
//post to http server XLSMessage resp = (XLSMessage) dataSource.executeRequest(msg);
//show what was returned from server marshaller.marshal( resp, System.out );
return resp;
i want to create a web service to this method so it will work as middle tire.
but i am getting an error, IWAB0489E Error when deploying Web service to Axis runtime axis-admin failed with {http://xml.apache.org/axis/}HTTP (500)Internal Server Error can you help me on this
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
posted
0
The code that you are showing presumably is using deCarta's Java (J2SE) Client API that is part of their DDS Web Servicesproduct.
What is unclear is how Axis fits into the picture. Unless you are using the deCarta Client API inside one of your own Axis web services, use of the code you show in a client (consumer) should be unrelated to problems of deploying the producer web service.
public class ReqGeoCode extends AbstractExample{ public String getGeoCode(String Countrycode,String Street,String BuildingNo,String Pincode) throws Exception{ try{ GeocodeRequest params = factory.createGeocodeRequest(); java.util.List addresses = params.getAddress(); addresses.add(newStructuredAddress(Countrycode,Street,BuildingNo,Pincode)); //System.out.println("------------------req"); XLSMessage msg = newXLSMessage(params, "GeocodeRequest");
//show what gets sent to server marshaller.marshal( msg, System.out );
//post to http server XLSMessage resp = (XLSMessage) dataSource.executeRequest(msg); //System.out.println("------------------res"); //show what was returned from server marshaller.marshal( resp, System.out );
Object obj=resp; String response=obj.toString();
return response; }finally{ super.close(); //release resources, in this case, the dataSource } } }
for this method iam extending one class which has some methods as metioned below......
/** Creates a new instance of AbstractExample */ public AbstractExample() { dataSource = newDataSource(); dataSource.setHeader(newHeader()); marshaller = newMarshaller(); }
//allow the DataSource to be configured via System.properties //default to HttpDataSource String dataSourceClassname= System.getProperties().getProperty("com.telcontar.openls.properties.DataSourceClass", "com.telcontar.openls.client.HttpDataSource"); props.setProperty("com.telcontar.openls.properties.DataSourceClass", dataSourceClassname); System.setProperty("http.proxyHost", "proxy.cognizant.com"); System.setProperty("http.proxyPort", "6050"); //get url from System.properties, default to localhost if not in System.properties props.setProperty("url", System.getProperty("url","http://wsdds2.dz.decarta.com/openls/openls")); //fixme DataSourceFactory dsFactory = new OpenlsDataSourceFactory(props);
//get a DataSource with the specified Properties return dsFactory.newDataSource(); }
StreetAddressType streetAddress = factory.createStreetAddress(); address.setStreetAddress(streetAddress); StreetNameType street = factory.createStreet(); streetAddress.setStreet(street); street.setValue(Street); Building building = factory.createBuilding(); building.setNumber(BuildingNo);
streetAddress.setStreetLocation(building); address.setPostalCode(Pincode); //the zipcode of fictional "Stickville" return address; }
protected void close(){ dataSource.close(); }
}
all this work fine but when i was creating client by eclipse it was stopping at [ November 12, 2008: Message edited by: prasanth duggirala ]
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35254
7
posted
0
It's hard to say what changes you need to make, because we don't know what that code is supposed to do, nor what it does right now. It's also very hard to read because you don't UseCodeTags; please go back and edit your post to use those.
You mentioned an error message - is there a stack trace to go with it? Where do you see this error, and what were you going when it happened? Is Axis otherwise installed correctly and happy?
Prasanth Duggirala
Ranch Hand
Joined: Dec 22, 2006
Posts: 36
posted
0
hi iam getting the responce as a XML i want to unmarshal the xml how can i do that can any one give any examples....
can any one give an example on unmarshaling the xml.
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
posted
0
Originally posted by prasanth duggirala: i want to seperate the values of the response.
can any one give an example on unmarshaling the xml.
Earlier you said:
Hi IWAB0489E Error when deploying Web service to Axis runtime ... all this work fine but when i was creating client by eclipse it was stopping at
This suggested to me that you had already tested the JAXB unmarshalling code and that it was working fine and that the problems only occurred when you were trying to integrate/deploy the code.
Isolate the JAXB code into a small program, force feed it the response that you have and see what happens. Even better - use it to formulate a unittest.
Addendum:
You are already using the JAXB marshaller which is created when you compile the XML schema for creating the request - use the unmarshaller to read the response.
If you're going to use a DocumentBuilder with a document which uses namespaces, then you should really call setNamespaceAware(true) on the DocumentBuilderFactory that creates it.
However I'm not convinced you need to do any DOM-manipulating code. A plain old XSLT transformation might be better, as Peer suggests.
Prasanth Duggirala
Ranch Hand
Joined: Dec 22, 2006
Posts: 36
posted
0
I have a doubt trans.transform(makeXml(), result); this does printing in console i want to change into string and return the string how we can do?
If we do so then if we call the method then the return type is string we can get the value.
the given code will can we create the webservice like this i have a doubt.. ---------- /* * ReqGeoCode.java */
//show what gets sent to server //marshaller.marshal( msg, System.out );
//post to http server @SuppressWarnings("unused") XLSMessage resp = (XLSMessage) dataSource.executeRequest(msg);
//show what was returned from server //marshaller.marshal(resp, System.out); List str; try { TransformerFactory factory = TransformerFactory.newInstance(); Transformer trans = factory.newTransformer(makeXslt()); Result result = new StreamResult(System.out); //trans.transform(makeXml(), result); str=(List) result; System.out.println("**********"+str.listIterator()); } catch(Exception e){ e.printStackTrace(); } return Pincode; }
iam getting this error !-- IWAB0489E Error when deploying Web service to Axis runtime axis-admin failed with {http://xml.apache.org/axis/}HTTP (500)Internal Server Error --!
In Server side error iam getting this @-- org.apache.axis.deployment.wsdd.WSDDException: Must include type attribute for Handler deployment! org.apache.axis.deployment.wsdd.WSDDException: Must include type attribute for Handler deployment! --@
then i canable to se one wsdl file created i tried to create a client for this then i got one more error @-- org.apache.axis.utils.JavaUtils isAttachmentSupported WARNING: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled. --@
any suggitions please....
Ted Addis
Greenhorn
Joined: Nov 19, 2008
Posts: 11
posted
0
prasanth, I am assuming you are using Eclipse 3.4
Do the following. 1. First decide on using Axis2 and install .WAR from axis 2 official site 2. Go to Axis2 download page and download Eclipse plugins at http://ws.apache.org/axis2/tools/index.html
3. If you haven't done, make sure you select the runtime web/app server in Eclipse ( windows- preference- server- runtime). It could be your tomcat/jboss
4. Similar to 3, select the web service Axis 2 runtime by selecting your Axis2 installation folder..
And finally in Project, right click - New - web service - web service client - then follow the steps and should work..
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
posted
0
There is also no need to write the response xml to a file unless you are processing monster responses. You can simply use a java.io.ByteArrayOutputStream, i.e.
Originally posted by prasanth duggirala: Can i use this method as a webservice which internaly calling deCarta webservice.
I don't see any problem using the code inside of a web service. Exposing this method as a web method makes really no sense, as you are working with XML-based technologies - you are handing the client unstructured plain text data when you could be handing them semi-structured XML data. While you may not want to return the data in the OpenGIS format, you should at least define an XML structure (preferably defined with XML Schema) that makes it easy for the client to work with (e.g. by pulling out the interesting bits with XPath).
Now in a constrained mobile environment you need to carefully assess whether the overhead of SOAP web services is even worth it. SOA Without SOAP: The Java ME Perspective
I'm getting a sudden sense of d�j� vu. Have a look at this topic.
any suggitions please....
Stop using WTP for building your web service, use the web service stack tools for a more "hands-on" approach. Once you get into trouble (which you obviously have gotten yourself into) it takes an awful lot of knowledge of the workings of Eclipse, WTP, ,Plugins and the web services stack to find out where these parts are not fully connecting (you can still edit any files in Eclipse).
Switch to a more modern Java web service API if you can. JAX-WS is the current standard but it requires at least Java SE 5 and it is already included in Java SE 6. Look here for an utterly barebones example. Of course you will have to move to deploying JAX-WS under Tomcat.
If you are limited to J2SE 1.4 then Axis2 is supposed to work.
But ultimately you have to decide whether SOAP web services are the right solution for your particular problem. [ November 19, 2008: Message edited by: Peer Reynders ]
Prasanth Duggirala
Ranch Hand
Joined: Dec 22, 2006
Posts: 36
posted
0
i have created to access the decarta webservice. ReqGeoCode.java which is obtaing some method from abstract class AbstractExample.java.
How can i create java to wsdl file for ReqGeoCode.java manually.
Will it takes the AbstractExample.java in the wsdl and all the jar required to handle the request and response.
Can we create a webservice which is optaining a deCarta web service.
how can we test the client whather the webservice is working.
which is easy way to create ReqGeoCode.java as a web method.
so i can use the getGeoCode(String Countrycode,String Street,String BuildingNo,String Pincode) and which it returns the string value.
Peer Reynders
Bartender
Joined: Aug 19, 2005
Posts: 2906
posted
0
Creating Web Services with Apache Axis should answer all your questions. However you are currently pursuing a much less than optimal path - your current solution will have to be replaced sooner than later.
Prasanth Duggirala
Ranch Hand
Joined: Dec 22, 2006
Posts: 36
posted
0
Hi all thanks for your support on web services and special thanks for Peer Reynders realy help me and it works superbly Peer.