aspose file tools*
The moose likes Web Services and the fly likes sending pdf file to client as byte array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "sending pdf file to client as byte array" Watch "sending pdf file to client as byte array" New topic
Author

sending pdf file to client as byte array

lokesh jain
Ranch Hand

Joined: Feb 21, 2009
Posts: 58
Hi, I am a newbie in Web Services. I have made a web service, which fetches some data from database and then makes a pdf file. Then in another java class, i am converting this pdf into byte array and then sending this byte array to client side and then at client side , I am again converting the received byte array to pdf. but I want to send the pdf file as attachement. Is that possible? If yes, can anyone send me the java code for that?

Thanks a million
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
What was wrong with the very extensive answer Peer gave you in this topic?
Nagendra E Loli
Greenhorn

Joined: Feb 23, 2009
Posts: 12
Hi.. I am very new to Web Service.. I created a Webservice. In that i have a method, to which the Client will send prameters.. The method ontains some string and 2 array parameters.. I am getting SAXException: deserialization error for that while sending the arrays to the method. Can anyone Help me to resolve this problem..

Thanks in advance
Nagendra E Loli
lokesh jain
Ranch Hand

Joined: Feb 21, 2009
Posts: 58
It seems that XSD created at runtime, is not matching the credentials.....only in this case we can get SAX error.
Nagendra E Loli
Greenhorn

Joined: Feb 23, 2009
Posts: 12
hi Thanks for the quick reply.. Can you please help me to get out of this problem... Can you please explain me what is the problem in detail... When i pass the Array tot he web service method then i am getting the "org.xml.sax.SAXException: No deserializer for" error....

Please explain me in detail..

Below are my java classes....

[u]CPServices.java[/u]

import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;

import org.apache.log4j.Logger;
import org.apache.soap.encoding.Hex;
import utility.ArrayString;

public class CPServices implements Serializable
{
/**
*
*/

HttpURLConnection _oConn = null;

public void smsMo(java.lang.String service_id, java.lang.String source_mobtel, java.lang.String sub_id,
java.lang.String keyword, java.lang.String transaction_id, java.lang.String short_code_suffix_ind,
java.lang.String short_code_suffix, AdditionalInfo[] array_of_info, SMSContent[] sms_contents)
{
System.out.println("Control Inside the smsMo()");

}

public void mtResp(java.lang.String service_id, java.lang.String source_mobtel,
java.lang.String destination_mobtel, java.lang.String delivery_channel,
java.lang.String transaction_id, java.lang.String ref_id, int notification_ind,
java.lang.String error_code, java.lang.String success_list, java.lang.String error_list)
{
System.out.println("Control Inside the mtResp()");
}
}



[u]SMSContent.java[/u]

import java.io.Serializable;

public class SMSContent implements Serializable
{
public java.lang.String content;

public java.lang.String ucp_data_coding_id;

public java.lang.String ucp_msg_class;

public java.lang.String ucp_msg_type;

public SMSContent()
{
}

public SMSContent(java.lang.String content, java.lang.String ucp_data_coding_id,
java.lang.String ucp_msg_class, java.lang.String ucp_msg_type)
{
this.content = content;
this.ucp_data_coding_id = ucp_data_coding_id;
this.ucp_msg_class = ucp_msg_class;
this.ucp_msg_type = ucp_msg_type;
}

public java.lang.String getContent() {
return content;
}

public void setContent(java.lang.String content) {
this.content = content;
}

public java.lang.String getUcp_data_coding_id() {
return ucp_data_coding_id;
}

public void setUcp_data_coding_id(java.lang.String ucp_data_coding_id) {
this.ucp_data_coding_id = ucp_data_coding_id;
}

public java.lang.String getUcp_msg_class() {
return ucp_msg_class;
}

public void setUcp_msg_class(java.lang.String ucp_msg_class) {
this.ucp_msg_class = ucp_msg_class;
}

public java.lang.String getUcp_msg_type() {
return ucp_msg_type;
}

public void setUcp_msg_type(java.lang.String ucp_msg_type) {
this.ucp_msg_type = ucp_msg_type;
}
}







[u]AdditionalInfo.java[/u]


import java.io.Serializable;

public class AdditionalInfo implements Serializable
{
public java.lang.String name;

public java.lang.String value;

public AdditionalInfo()
{
}

public AdditionalInfo(java.lang.String name, java.lang.String value)
{
this.name = name;
this.value = value;
}

public java.lang.String getName() {
return name;
}

public void setName(java.lang.String name) {
this.name = name;
}

public java.lang.String getValue() {
return value;
}

public void setValue(java.lang.String value) {
this.value = value;
}


}



the error which i got is as below...


- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: No deserializer for {http://DefaultNamespace}SMSContent</faultstring>
- <detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">sfjdev</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
So you're trying to send an object of class "SMSContent" across the wire? Did you configure both sides with the proper serializers/deserializers? It sounds as if that's missing.
Nagendra E Loli
Greenhorn

Joined: Feb 23, 2009
Posts: 12
[quote=Ulf Dittmer]So you're trying to send an object of class "SMSContent" across the wire? Did you configure both sides with the proper serializers/deserializers? It sounds as if that's missing.[/quote]

Yes.. Our client side will send the call the smsMo(). they will send the array of SMSContent.
The other side is not in my hand.. My client will send the requests to my service... At my side i implemented java.io.Serializable for the classes as i mentioned in the previous quote..

Please tell what i can do to get out of this problem... I hav to complete it within 2 days.. I got a deadline... it s my carrier matter..

Some one please help me...


Thanks & Regards
Nagendra E Loli
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
Implementing Serializable has nothing to do with this. You need to configure your SOAP toolkit with serializers and deserializers for the SMSContent class. Consult the documentation of whichever one you're using on how to do that.
Nagendra E Loli
Greenhorn

Joined: Feb 23, 2009
Posts: 12
[quote=Ulf Dittmer]Implementing Serializable has nothing to do with this. You need to configure your SOAP toolkit with serializers and deserializers for the SMSContent class. Consult the documentation of whichever one you're using on how to do that.[/quote]



Actually what i am doing here means... I am just coded whatever functionality i wanted in the CPServices.java class.... Then i am renaming that java file into "CPServices.jws"... i am not converting the Java file into the WSDL using and Axis tools.. Because in our company we are using Sun Application server 7 , JDK 1.4 & Tomcat 4.0..

Everything is lower version.. For time being we cant upgrade that one.. We have to upload the current project before tomorrow evening.. SO i need this in urgent.. Can you please send me any documentation or any web links to get out of this solution...

Thanks a lot for your valuable reply... Please help me regarding this...
Ganesh Kolhe
Greenhorn

Joined: Jul 05, 2009
Posts: 2
We have done with passing PDF byte array as String in String[] as return type where in we can pass other parameter from Web service
Please be at the blog
http://google-ecm.blogspot.com/2009/06/how-to-return-pdf-file-byte-array-from.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sending pdf file to client as byte array