• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

create and access web service with apache axis

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it will recive post request
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

This the method i am taling about i got in deCarta site only,

public XLSMessage 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));

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);

//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
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code that you are showing presumably is using deCarta's Java (J2SE) Client API that is part of their DDS Web Services product.

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.
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi IWAB0489E Error when deploying Web service to Axis runtime

do we need any extra jar files to be added in Tomcat or in the App

Below class is using some jars and for this class iam trying to create a webservice.

so that it will act as middle layer so that any one can access this method in the application so it will responce the GeoCode.

Can i use like this.Am i right to use like this any changes i have to make?

please help me on this.....

package com.deCarta.geoCode;
import com.telcontar.openls.xml.GeocodeRequest;
import com.telcontar.openls.xml.XLSMessage;


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......

package com.deCarta.geoCode;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

import com.telcontar.openls.client.DataSource;
import com.telcontar.openls.client.DataSourceFactory;
import com.telcontar.openls.client.OpenlsDataSourceFactory;
import com.telcontar.openls.xml.AbstractRequestParametersType;
import com.telcontar.openls.xml.Address;
import com.telcontar.openls.xml.Building;
import com.telcontar.openls.xml.ObjectFactory;
import com.telcontar.openls.xml.Request;
import com.telcontar.openls.xml.RequestHeader;
import com.telcontar.openls.xml.StreetAddressType;
import com.telcontar.openls.xml.StreetNameType;
import com.telcontar.openls.xml.XLSMessage;
/**
*
* @author ghendrey
*/
public abstract class AbstractExample {
protected DataSource dataSource;
protected ObjectFactory factory = new ObjectFactory();
protected Marshaller marshaller;

/** Creates a new instance of AbstractExample */
public AbstractExample() {
dataSource = newDataSource();
dataSource.setHeader(newHeader());
marshaller = newMarshaller();
}

private DataSource newDataSource(){

//these properties will configure the DataSource
java.util.Properties props = new java.util.Properties();

//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();
}

private Marshaller newMarshaller(){
try{
JAXBContext jc = JAXBContext.newInstance("com.telcontar.openls.xml");
marshaller = jc.createMarshaller();
marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
return marshaller;
}catch(JAXBException jaxbe){
throw new RuntimeException(jaxbe.getMessage());
}
}

private RequestHeader newHeader(){
try{
RequestHeader header = factory.createRequestHeader();
//header.setConfiguration(System.getProperties().getProperty("serviceConfiguration", "blue-steel"));
header.setClientName(System.getProperties().getProperty("clientName","cognizant-vg")); //fixme
header.setClientPassword(System.getProperties().getProperty("clientPassword","hg77t4"));//fixme
header.setSessionID("999");
return header;
}catch(JAXBException jaxbe){
throw new RuntimeException(jaxbe.getMessage());
}
}

@SuppressWarnings("unchecked")
protected XLSMessage newXLSMessage(AbstractRequestParametersType params, String methodName){
try{
Request request = factory.createRequest();
request.setRequestParameters(params);
request.setMethodName(methodName);
request.setMaximumResponses(new java.math.BigInteger("25"));
request.setRequestID("10");
request.setVersion("1.0");
XLSMessage msg = factory.createXLSMessage();
msg.getBody().add(request);
msg.setVersion(new java.math.BigDecimal("1.0"));
msg.setLang("en");
msg.setHeader(newHeader());
return msg;
}catch(JAXBException jaxbe){
throw new RuntimeException(jaxbe.getMessage());
}
}

protected Address newStructuredAddress(String Countrycode,String Street,String BuildingNo,String Pincode) throws Exception{
Address address = factory.createAddress();
address.setCountryCode(Countrycode);

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is the request

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:XLS ns1:lang="en" version="1.0" xmlns:ns1="http://www.opengis.net/xls">
<ns1:RequestHeader sessionID="999" clientName="cognizant-vg" clientPassword="hg77t4" configuration="blue-steel"/>
<ns1:Request maximumResponses="25" methodName="GeocodeRequest" requestID="10" version="1.0">
<ns1:GeocodeRequest>
<ns1:Address countryCode="US">
<ns1:StreetAddress>
<ns1:Building number="500"/>
<ns1:Street>Frank W. Burr Boulevard</ns1:Street>
</ns1:StreetAddress>
<ns1 ostalCode>07666</ns1 ostalCode>
</ns1:Address>
</ns1:GeocodeRequest>
</ns1:Request>
</ns1:XLS>

this is the responce iam getting

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:XLS ns1:lang="en" rel="4.3.2" version="1" xmlns:ns1="http://www.opengis.net/xls">
<ns1:ResponseHeader sessionID="999"/>
<ns1:Response numberOfResponses="1" requestID="10" version="1.0">
<ns1:GeocodeResponse>
<ns1:GeocodeResponseList numberOfGeocodedAddresses="1">
<ns1:GeocodedAddress>
<ns2 oint xmlns:ns2="http://www.opengis.net/gml">
<ns2 os>40.874312 -74.006446</ns2 os>
</ns2 oint>
<ns1:Address countryCode="US">
<ns1:StreetAddress>
<ns1:Building number="500"/>
<ns1:Street>FRANK W BURR BLVD</ns1:Street>
</ns1:StreetAddress>
<ns1 lace type="CountrySubdivision">NJ</ns1 lace>
<ns1 lace type="CountrySecondarySubdivision">BERGEN</ns1 lace>
<ns1 lace type="Municipality">TEANECK TWP</ns1 lace>
<ns1 lace type="MunicipalitySubdivision">TEANECK</ns1 lace>
<ns1 ostalCode>07666</ns1 ostalCode>
</ns1:Address>
<ns1:GeocodeMatchCode matchType="PATTERN MATCH" accuracy="1.0"/>
</ns1:GeocodedAddress>
</ns1:GeocodeResponseList>
</ns1:GeocodeResponse>
</ns1:Response>
</ns1:XLS>

i want to seperate the values of the response.

can any one give an example on unmarshaling the xml.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 unit test.

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.

Unmarshal Read Example
[ November 13, 2008: Message edited by: Peer Reynders ]
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:XLS ns1:lang="en" rel="4.3.2" version="1" xmlns:ns1="http://www.opengis.net/xls">
<ns1:ResponseHeader sessionID="999"/>
<ns1:Response numberOfResponses="1" requestID="10" version="1.0">
<ns1:GeocodeResponse>
<ns1:GeocodeResponseList numberOfGeocodedAddresses="1">
<ns1:GeocodedAddress>
<ns2 oint xmlns:ns2="http://www.opengis.net/gml">
<ns2 os>40.874312 -74.006446</ns2 os>
</ns2 oint>
<ns1:Address countryCode="US">
<ns1:StreetAddress>
<ns1:Building number="500"/>
<ns1:Street>FRANK W BURR BLVD</ns1:Street>
</ns1:StreetAddress>
<ns1 lace type="CountrySubdivision">NJ</ns1 lace>
<ns1 lace type="CountrySecondarySubdivision">BERGEN</ns1 lace>
<ns1 lace type="Municipality">TEANECK TWP</ns1 lace>
<ns1 lace type="MunicipalitySubdivision">TEANECK</ns1 lace>
<ns1 ostalCode>07666</ns1 ostalCode>
</ns1:Address>
<ns1:GeocodeMatchCode matchType="PATTERN MATCH" accuracy="1.0"/>
</ns1:GeocodedAddress>
</ns1:GeocodeResponseList>
</ns1:GeocodeResponse>
</ns1:Response>
</ns1:XLS>

I have return the object into an RespGeoCode.xml file so i thought i can seperate the data but iam getting as shown below...








40.874312 -74.006446




FRANK W BURR BLVD

NJ
BERGEN
TEANECK TWP
TEANECK
07666






i like to know how to seperate the spaces
the changes made to the code is shown below....

//show what was returned from server
marshaller.marshal(resp, System.out);

//Writing to File
try {
FileOutputStream fout = new FileOutputStream("Responce.xml");
//ObjectOutputStream oos = new ObjectOutputStream(fout);
//oos.writeObject(resp);
marshaller.marshal(resp, fout);
fout.close();

//Reading from file
String xmlFile = "Responce.xml";
File file = new File(xmlFile);
if (file.exists()){
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(xmlFile);
//Create transformer
Transformer tFormer = TransformerFactory.newInstance().newTransformer();
//Output text type
tFormer.setOutputProperty(OutputKeys.METHOD, "text");
//Write the document to a file
DOMSource source = new DOMSource(doc);

Result result = new StreamResult(System.out);
tFormer.transform(source, result);

}
else{
System.out.println("File not found!");
}
}
catch (Exception e){
System.err.println(e);
System.exit(0);
}
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one help me on this
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by prasanth duggirala:
i like to know how to seperate the spaces



By supplying the transformation with an appropriate XSLT style sheet.



Output:

[ November 18, 2008: Message edited by: Peer Reynders ]
 
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
*/

package examples.openls;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.StringWriter;
import java.util.List;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.w3c.dom.Document;

import com.telcontar.openls.xml.GeocodeRequest;
import com.telcontar.openls.xml.XLSMessage;


public class ReqGeoCode extends AbstractExample{
@SuppressWarnings("unused")
private boolean b;

@SuppressWarnings("unchecked")
public String getGeoCode(String Countrycode,String Street,String BuildingNo,String Pincode) throws Exception{
GeocodeRequest params = factory.createGeocodeRequest();
java.util.List addresses = params.getAddress();
b = addresses.add(newStructuredAddress(Countrycode,Street,BuildingNo,Pincode));


XLSMessage msg = newXLSMessage(params, "GeocodeRequest");

//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;
}

private static Source xmlStringToSource(String xmlText) {
return new StreamSource(new ByteArrayInputStream(xmlText.getBytes()));
}

@SuppressWarnings("unused")
private static Source makeXslt()
{
String xmlText ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<xsl:stylesheet "
+ "version=\"1.0\" "
+ "xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" "
+ "xmlns gx=\"http://www.opengis.net/xls\" "
+ "xmlns gg=\"http://www.opengis.net/gml\">"
+ "<xsl utput method=\"text\" encoding=\"UTF-8\"/>"
+ "<xsl:strip-space elements=\"*\" />"
+ "<xsl:template match=\"/\">"
+ "<xsl:apply-templates select=\"ogx:XLS/ogx:Response/ogx:GeocodeResponse/ogx:GeocodeResponseList\"/>" + "</xsl:template>"
+ "<xsl:template match=\"ogx:GeocodeResponseList\">"
+ "<xsl:for-each select=\"ogx:GeocodedAddress\">"
+ "<xsl:apply-templates select=\"ogg oint/ogg os\"/>"
//+ "<xsl:text> </xsl:text>"
//+ "<xsl:apply-templates select=\"ogx:Address\"/>"
+ "</xsl:for-each>"
+ "</xsl:template>"
+ "<xsl:template match=\"ogg os\">"
+ "<xsl:value-of select=\".\"/>"
+ "</xsl:template>"
/*+ "<xsl:template match=\"ogx:Address\">"
+ "<xsl:value-of select=\"ogx:StreetAddress/ogx:Building/@number\"/>"
+ "<xsl:text> </xsl:text>"
+ "<xsl:value-of select=\"ogx:StreetAddress/ogx:Street\"/>"
+ "<xsl:text> </xsl:text>"
+ "<xsl:value-of select=\"ogx lace[@type='MunicipalitySubdivision']\"/>"
+ "<xsl:text> (</xsl:text>"
+ "<xsl:value-of select=\"ogx lace[@type='Municipality']\"/>"
+ "<xsl:text>, </xsl:text>"
+ "<xsl:value-of select=\"ogx lace[@type='CountrySecondarySubdivision']\"/>"
+ "<xsl:text> , </xsl:text>"
+ "<xsl:value-of select=\"ogx lace[@type='CountrySubdivision']\"/>"
+ "<xsl:text> </xsl:text>"
+ "<xsl:value-of select=\"ogx ostalCode\"/>"
+ "<xsl:text> </xsl:text>"
+ "<xsl:value-of select=\"@countryCode\"/>"
+ "<xsl:text> </xsl:text>"
+ "</xsl:template>" */
+ "</xsl:stylesheet>";
return xmlStringToSource(xmlText);
}

@SuppressWarnings("unused")
private static Source makeXml(){
String xmlText = "";
try{
File file = new File("Responce.xml");
if (file.exists()){
TransformerFactory transformerFactory=TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (file);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
DOMSource source = new DOMSource(doc);
transformer.transform(source, result);
xmlText=writer.toString();
//System.out.println(xmlText);
}
}catch(Exception e){
System.out.println(e);
}
return xmlStringToSource(xmlText);
}
}

----------
public String getGeoCode(string USCode,String buildingnumber, String street, String pincode){

return pos;
}


can we get the pos value 40.874312 -74.006446
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks All
Peer Reynders your Code Real helps me Thanks for Supporting me i am new to this webServices...........

I got the answer for above asked question by adding this shown below code.
i can get the value in string return type..

public String getGeoCode(String Countrycode,String Street,String BuildingNo,String Pincode) throws Exception{
GeocodeRequest params = factory.createGeocodeRequest();
java.util.List addresses = params.getAddress();
b = addresses.add(newStructuredAddress(Countrycode,Street,BuildingNo,Pincode));
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);
marshaller.marshal(resp, System.out);

StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
//Writing to File
try {
FileOutputStream fout = new FileOutputStream("Responce.xml");
marshaller.marshal(resp, fout);
fout.close();
TransformerFactory factory = TransformerFactory.newInstance();
Transformer trans = factory.newTransformer(makeXslt());
trans.transform(makeXml(), result);
System.out.println(writer.toString());
}catch(Exception e){
e.printStackTrace();
}
return writer.toString();
}

Can i use this method as a webservice which internaly calling deCarta webservice.

if i can create which procedure is easy to using Axis or etc any Suggitions for me regarding this...

I tried to create webservice like this procedure link
http://www.eclipse.org/webtools/jst/components/ws/M3/tutorials/BottomUpWebService.html

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....
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).

Now if you need to use Axis 1 because you are limited to JAX-RPC (a more or less deprecated Java Web Services API) through J2ME Web Services(JSR-172) then Creating Web Services with Apache Axis is a good primer.

Just make sure that you understand the implications of contract first and contract last before you blindly start exposing your Java methods as web methods. (See also Starting Out and Webservice - WSDL or Java Class).

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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all thanks for your support on web services and special thanks for Peer Reynders realy help me and it works superbly Peer.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic