Web Services :: XML Input File - Parse It And Give Response To Client
Dec 12, 2014New to webservices. Can i get to create webservice which takes xml input. Parse it and gives the response to client.
View RepliesNew to webservices. Can i get to create webservice which takes xml input. Parse it and gives the response to client.
View Repliesi'm sending soap request but i'm getting html response it is leading to crash! how to parse html response?
View Replies View RelatedI am calling a SOAP based webservice using JAX-WS and a client jar. I want to get a request and response somehow and save it for audit purposes. How I can do this?
When I google it, only Handlers come up, but, as far as I understand, it is not applicable on client side.
this is my code...in my code i cant give input form my console...it takes input but it doesn't save in a target file..My code is :-
package filetester;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
[code]....
I have a SOAP Client with wsdl to send a query to a SOAP Server. Along with the SOAP response I am supposed to attach a generated csv file (Not required to open and read - just attach).
SOAP Handler has been implemented at server.
Since it is client code I am not supposed to paste the exact contents online.
I can create new SOAPMessage and use AttachmentPart to attach the file but I am stumped regarding where to set it as response. We have used only javax.xml and apache.cxf.
I want to print RAW Request Response XML to console. I have created the stubs using wsdl2java axis2. wsdl2java has created 2 java files, one for stub and one for callbackhandler.
I am trying with below method but getting null value for
operationContext.getMessageContext("Out") / operationContext.getMessageContext("In");.
public void SOAPLogHandler(Stub stub){
ServiceContext serviceConxt = stub._getServiceClient().getServiceContext();
//**** Enable the Cache to hold the last operation
OperationContext OperationContext = new OperationContext();
boolean cacheLastOperationContext = true;
OperationContext.setComplete(true); // Enable the Cache value
serviceConxt.setCachingOperationContext(cacheLastOperationContext);
serviceConxt.setLastOperationContext(OperationContext);
[code]....
I'm creating a SOAP Client with JS, this is my first time with webServices and I must have several mistakes in my code.
The poit is, with my code, I cant take acces to the WebService, but I don't know how to access to the methods inside. So the webservice gives me the following response:
<h1>Version</h1>
<p>Hi there, this is an AXIS service!</p>
<i>Perhaps there will be a form for invoking the service here...</i>
Instead of the correct XML for the method I'm calling.
This is the code of my SOAP client:
<html>
<script type="text/javascript">
function run(){
var objXMLHttpRequest = new XMLHttpRequest();
objXMLHttpRequest.open("GET", "http://localhost:8080/CrunchifyWS/services/Version?wdsl/", true);
objXMLHttpRequest.onreadystatechange = function () {
//alert(objXMLHttpRequest.readyState+" "+ objXMLHttpRequest.status);
[code]....
I think that te mistake should be in the XML part, but, as I said, this is my first time and I don't know what I'm doing.
When I try to do POST instead of GET I have this reposnse:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="w3.org/2001/XMLSchema"; xmlns:xsi="w3.org/2001/XMLSchema-instance">; <soapenv:Body> <soapenv:Fault> <faultcode xmlns:ns1="xml.apache.org/axis/">ns1:Client.NoSOAPAction</…; <faultstring>no SOAPAction header!</faultstring> <detail> <ns2:hostname xmlns:ns2="xml.apache.org/axis/">WebServices-PC</…; </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope>
I need to invoke a restful webservice Client(Rest) from my Webapp based on some scheduler . Also I need to persist the data which the webservice returns in response. So basically-
1. Scheduler triggers, I need to build the rest service request (JSON) and invoke it.
2. Capture the response of the webservice and persist the data in DB.
Technical stack used- Spring MVC
I would like to access a third party websevice using a Java client that I generated with JAX-WS wsimport, based on the WSDL provided (I am using a Maven plugin).
For quite a while I was unable to retrieve a useful response, not in the Java client and also not in SoapUI, until I found out that I had to enable WS-A on the request. In SoapUI this now results in the expected response, but what must I do to also 'enable' WS-A in the Java client? Do I maybe have to alter the WSDL, or add a parameter to wsimport?
I found some documentation on WS-A online, but so far could not find an answer.
I generated a WebService from a WSDL using JAXWS and import the finally generated WSDL to my SOAPUI to send out the request and view the response. For some reason, I always have to set WSS TimeToLive as 1000 in the request properties, else I get an error in the response. Now, I generated a client from the WSDL. I wonder if I need to set the WSS TimeToLive here as well
View Replies View RelatedI have an apache server with rest APIs accepting Json object and produce Json object.testing the sever using Chrome advanced rest client show no problems.I then tried to create a jave client, using org.jboss.resteasy:
public T sendPostRequest(String url, T input) throws Exception {
ClientRequest request = getNewClientRequest(url);
ObjectMapper om = new ObjectMapper();
final String body = om.writeValueAsString(input);
request.body(MediaType.APPLICATION_JSON, body);
final ClientResponse<String> responseObj = request.post(String.class);
validateResponseString(url, responseObj);
String responseString = responseObj.getEntity(String.class);
responseObj.releaseConnection();
[code]....
I want to write one REST client program for POST request ,request and response is in JSON Format.
public String getAck() {
HttpURLConnection httpConnection = null;
URL url=null;
try {
url = new URL("http://test:8080/ils/main");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
[Code]....
Line OutputStream os = httpConnection.getOutputStream();
I am getting connection time out problem
I understand the stack part of it, just not the loop, specifically how you give the user more than one option to input.
Implement a printer driver that handles incoming print jobs. The driver will behave in the following manner:
- Loop giving the user the following options: ADD print job, DELETE latest print job, and
QUIT
- Recording the following information from each job: computer name, document name, and
number of pages
- When the user chooses to ADD, add a new print job to the top of the stack
- When the user chooses to DELETE, pop off the latest print job and output to the screen
which job has just been deleted
- When the user chooses to QUIT, output the print jobs still in the stack (in order from top
to bottom)
- Output must include all relevant information for each job.
The project is to develop the game Translate the Word .... It is asking user to translate a word proposed to and check if the input response is correct. At the end of the game score will be calculated and displayed.
Game Play :
1 - Ask the user to specify , through the console , its name and the number of words to offer . It is up to you to handle exceptions (eg number of words greater than the number you provided )
2 - Recover user response ( the word translated ) and check whether to continue . (eg you want to continue (y / n)) after each proposal.
3 - compare the response of the user with that which is preset for the word in question .
4 - Show the score at the end ( or at the breakpoint ) .
5 - Save the file in a user name , the score , the number of questions and the start date and end of the game played .
Some notes to consider :
1 - The language (eg, English - French , English - Arabic , etc. . ): It is up to you to specify the language adopted in the game and inform the user of your choice.
2 - The word bank to offer : It is up to you to develop the appropriate means to get the words to propose to the user. That said , the words and their translations can be retrieved :
a. a TXT file
b . an XML file . ( Tutorials DOM and SAX )
c . CSV file ( OpenCSV Tutorial )
d. a database ( Tutorial Access)
e . through APIs (eg Wordnet and google translate etc . ) .
f . a combination of the previous options a, bc , d and / or e . (eg words stored in a txt file and answers retrieved from the api google translate)
g . etc. .
Examples of files and databases are attached to the project statement . You will need to add one or more external libraries to your project. Click here for details on adding external libraries to Netbeans .
3 - A user will be associated with the question score if he can translate the word correctly. The score for each question can be calculated based on the number of words / questions to be proposed .
Development : In this project you will need at least a class called Question to encapsulate the word and its translations and provide all necessary methods to manipulate the object type Question.
An interface called IParser to make extensible project. Any class that implements IParser is a parser file (XML , TXT , CSV , etc.). / Database. In your project there will be a single class that implements IParser and will be used to retrieve words and their translations.
Add the ability to store the questions and answers of the user on the hard disk. Make the class Serializable Question
I want to parse a java file (i.e., I need write some code which understand the content of a given java file--> the name of this java file will be entered as input). Then, after my code understand the content of the given java file, map this java file into another target language or platform. the output from my code is the new file which can run on the target language or platform.in the current state, I want to write some code which can understand a java file and can parse its content and display it on the console.
View Replies View RelatedI have written my program result into a json file but i am getting json file in below format.
{"one":"one","two":"two","three":"three"}
but I have lot of entries to write into json finally it become unreadle format which is not very compart to read.
Is there any way to format or writing line by line into json file like below format,
{
"one":"one",
"two":"two",
"three":"three"
}
I have a flat file (.txt) with contents in a predefined format. I need to parse and look for a particular content and update it. How can i achieve this using Java.
View Replies View RelatedI have just started to work on Java EE and I am not able to put the refrence of css and javascript in jsp page.
My senario is below: I have created script file inside myJavaScript Folder like Web Container-> myJavaScript ->Home.js. Similarlly for css:Web Container-> myCss ->Home.css.
My Jsp page palced inside Like: Web Container-> Home ->Home.jsp.
How to give the reference of js and css file in my Home.jsp page.
Can you tell me or give a complete resource of file I/O, serialization!
View Replies View RelatedCreating a file upload servlet to accept a CSV and parse for insert into a database, however, whenever I click submit, it always seems to open a new tab/window. Below is the method I have that builds the upload form: (Using GWT 2.4)
private void buildUpload(){
LayoutContainer headerContainer = new LayoutContainer(new ColumnLayout());
headerContainer.setStyleAttribute("padding", "5px");
add(headerContainer);
NamedFrame hiddenFrame = new NamedFrame("uploadFrame");
final FormPanel form = new FormPanel(hiddenFrame);
[Code] .....
Is there something I'm missing? or something I've added that makes it open a new tab/window?
I have a class that do a soap request to a web service , the response is containing a base64 string repressing a file content , how can i send this string to a servlet (maybe any other way) to send it to the user as a downloaded file .
View Replies View RelatedThis issue is regarding response from the servlet
I have written a code to download .csv file with records from DB.
To download records i am uploading a .CSV file containing telephone number.
After downloading the .CSV file page is not getting refreshed.
Below is the code snippet i am using,where i am setting response content type as test/csv.
ServletOutputStream op = resp.getOutputStream();
// Set content type of output
resp.setContentType("text/csv");
resp.setHeader("Content-Disposition", "attachment; filename="test"");
op.flush();
op.close();
How that page will get refreshed after csv file download or after response.
I have a given WSDL file (around 1MB) and inside of the file they have many request and response types.
I have to generate JAR from it so I could import it on my current project and use it
I have tried using this: [URL]....
but it only generated 1 stub file and a 1 callback handler java files and its size is around 60MB.
WHat I need to is to generate seperate class file per response / request type... Is there a way to do it?
Java Code:
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class logBook {
public static void main(String[] args) throws FileNotFoundException
[Code] ....
So far this is the code I have. It will successfully read the contents of the file(which are below in quotations) and write them to the designated file. My issue is totaling the corresponding costs to their services and then writing that to the file. The if and else if clauses above do not work but how is it that I can get them working?
"John; 67.00; Dinner ; Aug 12 2013;
Bob; 200.00; Conference; Sep 11 2013;
Clara; 450.00; Lodging; Oct 25 2013;
Jamie; 450.00; Lodging; Oct 28 2013;
Rachel; 67.00; Dinner; Nov 11 2013;
Richard; 200.00; Conference; Dec 17 2013;
Nick; 67.00; Dinner; Jan 05 2014;"
I have downloaded the target page's html-file successfully, but how can I find out WHEN that version had its latest update?
Here's how the page is downloaded:
public void dlPage(URL url) {
try {
br = new BufferedReader(new InputStreamReader(url.openStream()));
fileOut = new BufferedWriter(new FileWriter(url.getHost()+".html"));
while( (line=br.readLine() ) != null ) {
fileOut.write(line);
fileOut.write("
[Code
I was thinking of using URLConnection's method getLastModified() for comparison. But dont have a clue how to read it from this file. Am I perhaps solving the download-part incorrectly?
Snapshot downloaded file text:
I am trying web service first time so want to client application which will consume webservice which are hosted online for testing purpose
now i want to call some methods defined in this wsdl [URL]....
can anyone tell how should i invoke methods using stand alone java file no eclipse which jar files should i use ?