Hi, this is my final project. I have generated an xml string, this is my code:

import java.io.StringReader;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="java.io.*" %>
<%@page import="recipe.*" %>

<html>
<head>
<title>RECIPE</title>
</head>
<body>

<%
// Instantiate the generated Service
   Recipe service = new Recipe();
        
// Get the port using port getter method generated in CalculatorService
   RecipePortType port= service.getRecipePort();
        
// Invoke the remote method
   FilterRequestType req = new FilterRequestType();
   FilterResponseType resp = port.filter(req);
   String xmlResult = resp.getRecipelist();

// Create an instance of the DOM parser and parse the document
   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   DocumentBuilder db = dbf.newDocumentBuilder();
   Document doc = db.parse(new InputSource(new StringReader(xmlResult)));

// Begin traversing the document
   traverseTree(doc, out);
%>


<%   .......................................(the rest of the code)

whenever i run it in my browser, there will be error like this:

An error occurred at line: 39 in the jsp file: /assignment2/domrecipe.jsp
InputSource cannot be resolved to a type
36: // Create an instance of the DOM parser and parse the document
37: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
38: DocumentBuilder db = dbf.newDocumentBuilder();
39: Document doc = db.parse(new InputSource(new StringReader(xmlResult)));
40:
41: // Begin traversing the document
42: traverseTree(doc, out);

and this:

root cause

java.net.MalformedURLException: no protocol: <?xml version="1.0" encoding="UTF-8"?>
(and then the xml string)


so, basically, the xml string has been read, but there are errors in it... can someone help me..
thanks..

Hi,
i am very new to webservices.My webservice has to return xmlstring as response. like.. <xml version.....><Returncode>G</ReturnCode><folder name = 'salesfolder' value ='100'></folder> I got simple samples which return a string,but not xmlstring how can i proceed.....plz....
I have to develop webservices using JAX-WS ,JBoss Application server,JBossWS-native......
Can anyone plz..help me out with steps.....

Thanx in Advance....

Hi,
thanks for replying i have gone through that thread before posting,but i am not getting it.
Is that thread is a service or client as i am seeing jsp tags and also its not returning..

I have gone through some links and this is what i got.Please correct me ....
1. i wrote a method which takes string as a parameter.
2. In the method, i am generating a xml Document and transforming that DOM to string and returning that string.
Is i am folowing the correct way?.
In some articles i came to know that it should returning a document type,so that will as string i correct format(tags).Is it correct...

please suggest me.....

Hi, this is my final project. I have generated an xml string, this is my code:

import java.io.StringReader;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="java.io.*" %>
<%@page import="recipe.*" %>

<html>
<head>
<title>RECIPE</title>
</head>
<body>

<%
// Instantiate the generated Service
   Recipe service = new Recipe();
        
// Get the port using port getter method generated in CalculatorService
   RecipePortType port= service.getRecipePort();
        
// Invoke the remote method
   FilterRequestType req = new FilterRequestType();
   FilterResponseType resp = port.filter(req);
   String xmlResult = resp.getRecipelist();

// Create an instance of the DOM parser and parse the document
   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   DocumentBuilder db = dbf.newDocumentBuilder();
   Document doc = db.parse(new InputSource(new StringReader(xmlResult)));

// Begin traversing the document
   traverseTree(doc, out);
%>


<%   .......................................(the rest of the code)

whenever i run it in my browser, there will be error like this:

An error occurred at line: 39 in the jsp file: /assignment2/domrecipe.jsp
InputSource cannot be resolved to a type
36: // Create an instance of the DOM parser and parse the document
37: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
38: DocumentBuilder db = dbf.newDocumentBuilder();
39: Document doc = db.parse(new InputSource(new StringReader(xmlResult)));
40:
41: // Begin traversing the document
42: traverseTree(doc, out);

and this:

root cause

java.net.MalformedURLException: no protocol: <?xml version="1.0" encoding="UTF-8"?>
(and then the xml string)


so, basically, the xml string has been read, but there are errors in it... can someone help me..
thanks..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.