File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes How call webservices(Wsdl) to phonegap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How call webservices(Wsdl) to phonegap" Watch "How call webservices(Wsdl) to phonegap" New topic
Author

How call webservices(Wsdl) to phonegap

revathi kurum
Ranch Hand

Joined: Dec 04, 2013
Posts: 58
Hi,

Actually i created webservices if i will test this webservices it will give WSDL file by using that one i can get the result in client(phonegap)



package sss;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

/**
*
* @author Compaq
*/
@WebService()
public class Job {

/**
* Web service operation
*/
@WebMethod(operationName = "carrer")
public String carrer(@WebParam(name = "L")
String L) throws IOException, ParserConfigurationException, SAXException
{

StringBuilder str=new StringBuilder();
//out.println("Hai");

try
{

URL url = new URL("http://api.careerbuilder.com/v1/jobsearch?DeveloperKey=WDH36716NGKGL3VVCDN8&locationcity="+L);

URLConnection uconn=url.openConnection();

HttpURLConnection conn=(HttpURLConnection)uconn;

conn.connect();

Object content=conn.getContent();

InputStream stream=(InputStream) content;

DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder=docBuilderFactory.newDocumentBuilder();

Document doc=docBuilder.parse(stream);

doc.getDocumentElement().normalize();

//str.append("<career>");

NodeList joblist=doc.getElementsByTagName("JobSearchResult");

for(int i=0;i<joblist.getLength();i++)

{

Node job=joblist.item(i);

if(job.getNodeType()== Node.ELEMENT_NODE){

Element firstPersonElement=(Element)job;

NodeList companytag=firstPersonElement.getElementsByTagName("Company");

Element com_name=(Element)companytag.item(0);

NodeList textComList=com_name.getChildNodes();

NodeList titletag = firstPersonElement.getElementsByTagName("JobTitle");

Element title_name = (Element) titletag.item(0);

NodeList textTitleList = title_name.getChildNodes();

NodeList didtag = firstPersonElement.getElementsByTagName("DID");

Element did_text = (Element) didtag.item(0);

NodeList textDidList = did_text.getChildNodes();

String title = ((Node) textTitleList.item(0)).getNodeValue().replaceAll("&","a");

String company = ((Node) textComList.item(0)).getNodeValue().replaceAll("&","a");

String did = ((Node) textDidList.item(0)).getNodeValue().replaceAll("&","a");

// str.append("<br>"+title+"<br>"+company+"<br>"+did);

//str.append("<results>");

// str.append("<jobtitle>");

str.append(company);

//str.append(title);

// str.append(System.getProperty("line.separator"));

// str.append("</jobtitle>");

// str.append("<company>");

// str.append(company);

//str.append(System.getProperty("line.separator"));

// str.append("</company>");

// str.append("<jobid>");

// str.append(did);

// str.append(System.getProperty("line.separator"));

// str.append("</jobid>");

// str.append("</results>");

}

}

}catch(Exception e){

System.out.println(e);

}

//str.append("</career>");

// out.println(str.toString());

String data=str.toString();



return data;
}
}

problem is its showing error in server i mean it will not come any WSDL file like below showing error


Exceptions details : null
java.lang.NullPointerException at java.io.File.(File.java:222) at org.glassfish.webservices.monitoring.WebServiceTesterServlet.initializePort(WebServiceTesterServlet.java:505) at org.glassfish.webservices.monitoring.WebServiceTesterServlet.doGet(WebServiceTesterServlet.java:165) at org.glassfish.webservices.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:100) at org.glassfish.webservices.JAXWSServlet.doGet(JAXWSServlet.java:195) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:239) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) at com.sun.grizzly.ContextTask.run(ContextTask.java:69) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) at java.lang.Thread.run(Thread.java:619)


Thanks advance
Surendra Kumar
Ranch Hand

Joined: Jul 04, 2006
Posts: 229
You mean to generate WSDL file from Java code? Use wsgen utility or java2wsdl of Apache Axis from command line.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How call webservices(Wsdl) to phonegap
 
Similar Threads
How to build unified client application which could able to understand multiple web services
New line using StringBuilder class
Problem in delete form
help with web service to display xml file contents using netbeans
JPA & Persistency problems