Hi sebbaz,
I have been working on my error and i was quite successful in doing it
now my code is working, *but now i want to make my own string soap
request and passing it on in the ResponseBody() as a String or stream
and not as a file*, The new code Snippet is as follows:
static Logger log = Logger.getLogger("alabotTester.AlaMsg");
public void SOAPreq()
{
try {
String inp = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soap:Header><AuthenticationTokenxmlns=\"http://user.mynamesspace.com\">.................
...........................</soap:Body></soap:Envelope>"; *//This is My
String SOAP Request*
try {
BufferedWriter out = new BufferedWriter(new FileWriter("name.xml"));
out.write(inp);
out.close();
} catch (IOException e) {
}
getResp("name.xml");*// Above String is passed as a File to be
posted, where as i want this to be posted as a string and not as
file. *
}
*////Function return Response of posted XML.*
public String getResp(String strXMLFilename) throws Exception {
String strURL = "http://xyz.com/a/b/WebServices";
String response ="";
// Get SOAP action
String strSoapAction = "Post";
// Get file to be posted
File input = new File(strXMLFilename);
// Prepare HTTP post
PostMethod post = new PostMethod(strURL);
// Get target URL
// Request content will be retrieved directly
// from the input stream
RequestEntity entity = new FileRequestEntity(input, "text/xml;
charset=ISO-8859-1"); *//* *File is being posted in Request entity i
want it
to be
stream or string.*
post.setRequestEntity(entity);
post.setRequestHeader("SOAPAction", strSoapAction);
// Get HTTP client
System.out.println("httpclient>>>>>>");
HttpClient httpclient = new HttpClient();
// Execute request
try {
int result = httpclient.executeMethod(post);
response = post.getResponseBodyAsString();
System.out.println("String
Response"+post.getResponseBodyAsString());
}
finally {
// Release current connection to the connection pool once you
are done
post.releaseConnection();
}
return response;
}
*I Basically want to know how i can pass the Soap String in post body as
a string or stream without using file so that i can give as many users
access as i want currently through file its not possible.*
sebb wrote:
On 04/06/2008, Nishant Gupta <[EMAIL PROTECTED]> wrote:
hi,
I am Facing issues regarding posting the soap xml as a string (it was
working fine till i was using file) in setting post.requestEntity();
PostMethod post = new PostMethod(strURL);
// Get target URL
// Request content will be retrieved directly
// from the input stream
String xm = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soap:Header><AuthenticationToken
xmlns=\"http://user.mynamesspace.com\">..................................</soap:Body></soap:Envelope>";
// String to be passed
RequestEntity entity1 = new
StringRequestEntity(xm,"SOAPREQUEST",""); //*my error is
here.* I have tried passing
And the error is?
//StringRequestEntity(content) and
//StringRequestEntity(content, contenttype, charset);
//RequestEntity entity = new FileRequestEntity(input,
"text/xml; charset=ISO-8859-1"); //file was working fine
earlier
post.setRequestEntity(entity1);
post.setRequestHeader("SOAPAction",
strSoapAction);
// Get HTTP client
HttpClient httpclient = new HttpClient();
// Execute request
try {
int result = httpclient.executeMethod(post);
response = post.getResponseBodyAsString();
System.out.println("String
Response"+post.getResponseBodyAsString());
}
finally {
// Release current connection to the connection pool once you
are done
post.releaseConnection();
}
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
--- Begin Message ---
Hi sebbaz,
I have been working on my error and i was quite successful in doing it
now my code is working, *but now i want to make my own string soap
request and passing it on in the ResponseBody() as a String or stream
and not as a file*, The new code Snippet is as follows:
static Logger log = Logger.getLogger("alabotTester.AlaMsg");
public void SOAPreq()
{
try {
String inp = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soap:Header><AuthenticationTokenxmlns=\"http://user.mynamesspace.com\">.................
...........................</soap:Body></soap:Envelope>"; *//This is My
String SOAP Request*
try {
BufferedWriter out = new BufferedWriter(new FileWriter("name.xml"));
out.write(inp);
out.close();
} catch (IOException e) {
}
getResp("name.xml");*// Above String is passed as a File to be
posted, where as i want this to be posted as a string and not as
file. *
}
*////Function return Response of posted XML.*
public String getResp(String strXMLFilename) throws Exception {
String strURL = "http://xyz.com/a/b/WebServices";
String response ="";
// Get SOAP action
String strSoapAction = "Post";
// Get file to be posted
File input = new File(strXMLFilename);
// Prepare HTTP post
PostMethod post = new PostMethod(strURL);
// Get target URL
// Request content will be retrieved directly
// from the input stream
RequestEntity entity = new FileRequestEntity(input, "text/xml;
charset=ISO-8859-1"); *//* *File is being posted in Request entity i
want it
to be
stream or string.*
post.setRequestEntity(entity);
post.setRequestHeader("SOAPAction", strSoapAction);
// Get HTTP client
System.out.println("httpclient>>>>>>");
HttpClient httpclient = new HttpClient();
// Execute request
try {
int result = httpclient.executeMethod(post);
response = post.getResponseBodyAsString();
System.out.println("String
Response"+post.getResponseBodyAsString());
}
finally {
// Release current connection to the connection pool once
you are done
post.releaseConnection();
}
return response;
}
*I Basically want to know how i can pass the Soap String in post body as
a string or stream without using file so that i can give as many users
access as i want currently through file its not possible.*
sebb wrote:
On 04/06/2008, Nishant Gupta <[EMAIL PROTECTED]> wrote:
hi,
I am Facing issues regarding posting the soap xml as a string (it was
working fine till i was using file) in setting post.requestEntity();
PostMethod post = new PostMethod(strURL);
// Get target URL
// Request content will be retrieved directly
// from the input stream
String xm = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soap:Header><AuthenticationToken
xmlns=\"http://user.mynamesspace.com\">..................................</soap:Body></soap:Envelope>";
// String to be passed
RequestEntity entity1 = new
StringRequestEntity(xm,"SOAPREQUEST",""); //*my error is
here.* I have tried passing
And the error is?
//StringRequestEntity(content) and
//StringRequestEntity(content, contenttype, charset);
//RequestEntity entity = new FileRequestEntity(input,
"text/xml; charset=ISO-8859-1"); //file was working fine earlier
post.setRequestEntity(entity1);
post.setRequestHeader("SOAPAction",
strSoapAction);
// Get HTTP client
HttpClient httpclient = new HttpClient();
// Execute request
try {
int result = httpclient.executeMethod(post);
response = post.getResponseBodyAsString();
System.out.println("String
Response"+post.getResponseBodyAsString());
}
finally {
// Release current connection to the connection pool once you
are done
post.releaseConnection();
}
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--- End Message ---
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]