Srinath Kannan

Greenhorn
+ Follow
since Jan 11, 2011
Srinath likes ...
Eclipse IDE Tomcat Server Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Srinath Kannan

Hi Josh,

I extended the PatternLayout class and implemented the header. It works.

One change, we have to append line.separator character at the end of the string returned by overidden getHeader() method. if we dont append it, the first line logged comes along with the header line.



Thankyou very much.

Hi,

I have semi-colon separated values logged to a csv file using log4j. Now i wanted to write a header in first line [only once, everyday]. How this can be done?

Example
message id, file name, start time, end time, status
MSGID1000;SAMPLE.TXT;01:05:55;07:08:44;OK
MSGID1000;SAMPLE.TXT;01:05:55;07:08:44;NOK
Hi,

I have semi-colon separated values logged to a csv file using log4j. Now i wanted to write a header in first line [only once, everyday]. How this can be done?

Example
message id, file name, start time, end time, status
MSGID1000;SAMPLE.TXT;01:05:55;07:08:44;OK
MSGID1000;SAMPLE.TXT;01:05:55;07:08:44;NOK
Hi Matthew,

Thanks your comments!

All these days i was using option 2, from now i will use option 1. Other than readability, like in terms of memory allocation / performance do you see any difference? Is that going for option 1 guarantee's correct de-allocation at the right time!
13 years ago
Hi,

Whenever i code in Java, i had this habit of declaring variables, stacking them on top of method! In my perception i did this thinking that it improves clarity, readability.. also it was like a code beautification!

I am aware of the following

1 . Usually one would declare the variables/references in the top of method to decide its scoping..meaning they would require the variable or reference in the catch or finally block

2 . Declaring variables/references in the top of method and initializing them with Null or some values! would lead to Null exceptions if not instantiated inside subsequent parts of code

When i googled on this, It was said in some forum "that declare variable close to where you need it!" because its easy for JVM while doing deallocation!

Please see the below sample code snippet and help me to understand which is the best option in terms of coding standard / de-allocation?

Option 1:



Option 2:



Comparing option 1 and 2! what difference do you see in terms of coding standard / de-allocation?


13 years ago
Hi,

I have created a JMS application to interface with MQ series for sending/receiving messages. The application works fine.

I was wondering when does our application actually interfaces [starts a connection] with MQ

Is it when after we create the queue session object or the queue connection object or when we call the start() method from queueConnection reference?

There are "for loops" inside message sending program, which keep sending messages to same queue & queue manager until a condition is reached. So i was worried if i am opening the connection un-necessarily every time when i send each message for each iteration!

I wanted to make sure that i use the same session and connection for each iteration in the loop because the queue and queue manager name are the same! I assume that creating connection/sessions each time will degrade performance and its not necessary!

So in the above shown code, at which line the actual connection with MQ starts?

Is it Line no 6 or 7 or 8 or 12 or 13?

I can put that line top of the message sending method once for all, so that i am avoiding performance issues!.
13 years ago
Hi,

I have created a JMS application to interface with MQ series for sending/receiving messages. The application works fine.

I was wondering when does our application actually interfaces [starts a connection] with MQ

Is it when after we create the queue session object or the queue connection object or when we call the start() method from queueConnection reference?

There are "for loops" inside message sending program, which keep sending messages to same queue & queue manager until a condition is reached. So i was worried if i am opening the connection un-necessarily every time when i send each message for each iteration!

I wanted to make sure that i use the same session and connection for each iteration in the loop because the queue and queue manager name are the same! I assume that creating connection/sessions each time will degrade performance and its not necessary!



So in the above shown code, at which line the actual connection with MQ starts?

Is it Line no 6 or 7 or 8 or 12 or 13?

I can put that line top of the message sending method once for all, so that i am avoiding performance issues!.




Thanks Lingan

I am a novice in web services and i developed web services using code-first approach.

The link which you provided, i already seen it, its difficult to understand. Can you provide some other example?


13 years ago
Hi,

I am completed developing web service using JAX-WS. Now i wanted to throw SOAPFault with customized error codes on certain conditions.
I gooogled on this topic, but i did not find any good/clear example to do this.

I need the following

1. A basic clear good example for throwing SOAPFault.

2. Why cant we just create custom exception classes by extending java.lang.Exception and annotating @webfault and throw this custom exception when required?

For example



3. I read in some article that we need a bindings.xml file to configure and say the fault details? I did not understand this!
Also, its mentioned that @WebFault annotation should not be used by the programmer! Why?


Please help in this regard.

Thanks
13 years ago
Hi Naren,

soapMsg.getSOAPHeader() is not working! Still null is returned!

Please help


13 years ago
Thank you for your comments.

I have resolved the stream corrupt exception. Using disassembler i found that there is method in InputStream class which returns byte array. I passed this byte[] to FileOutputStream it worked.



I also tested transferring pdf, it worked till 5 MB. Above 5MB i started getting OutOfMemory Exception. So maximum size limit is 5MB.

Now i wanted to read user name, password and time stamp token from SOAPHeader for authentication. So i created SOAPHandler and put the following code in the handleMessage method, but SOAPHeader is null.



SOAP request is



When the above request is sent, the SOAPHeader is null. Please help me in this regard.
13 years ago
Thanks Naren. After going through many posts under webservices category, i successfully created the webservice using DataHandler object which appears as byte array in client java program [in wsdl the return type is xs:base64Binary]. But there is a new problem now!

I did this implementation using notepad and used wsgen and wsimport tools available with java 6 sdk. After publishing the webservice using java 6 lightweight sever and when i used the wsimport to generate the classes for client program the datahandler object was represented as byte array. I used FileOutputStream to write byte array to a file with pdf extension, it worked fine download pdf operation worked.



Then i tried the same migrating to web application using eclipse ide, this time the following are the new things i did
created sun-jaxws.xml file
declaring WSServletContextListener in web.xml
using jax-ws libraries [copied some 22 jar files to WEB-INF/lib directory]

Service was successfully published. I used wsimport to generate class files for client program, but this time DataHandler object was represented as DataHandler and not byte array.



While writing the data in object output stream i am getting stream corrupt exception.

I have the following questions
1. Why java return type for the operation changes when the service is published in web application? How to solve streamcorrupt exception?
2. sending attachments using datahandler or byte array [return type is xs:base64Binary]! Is this a recommended/effective approach?
3. is there any restrictions in terms of file size, because the file contents are transferred in soap message? if so what is the maximum file size supported?
4. what is advantage of other approach like using SAAJ, MTOM, Attachment with content id and mime type tags?
5. when i tested this in SOAP UI, after getting the response in the response tab/screen i see the binary data, but in the bottom of screen Attachments are not sensed.i.e SOAP UI is not recognizing the binary attachment data as attachment!
13 years ago
Hi Naren,

Yes its exactly the reverse. Client will request an attachment [pdf/document] by sending the file name in SOAP request. Webservice will identify the document and send it as an attachment back in SOAP response.

I am new to webservice implementations. I have conceptual understanding and i have implemented an simple webservice using JAX-WS API and its working fine, but i want modify it for sending attachments to client. I am familiar with bottom-up approach.

After searching in web, i found that an attachment can be sent as MIME part or binary stream. Like returning byte array or DataHandler object! I dunno whether MIME part or binary is recommended or which one is easy?

If you could help me with clear simple example or code snippet using JAX-WS and SAAJ, then i can easily catch up.

Thanks
Srinath
13 years ago
Hi,

I am looking for an good example which shows how to send an soap attachment [pdf file] from a java webservice to a java client program. The java client program should download the pdf file from webservice. I have already developed a sample webservice using JAX-WS. Now i wanted to modify the webservice to send attachments to client. Can this be done using SAAJ?

I tried searching, almost 90 % of the examples shows file upload..i.e sending attachments from client to webservice...but i need an example for file download!

Can this be achieved using JAX-WS and SAAJ?
13 years ago