- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
由于我是 Web 服务的新手,您能告诉我问题的答案吗?我的问题是
I want to implement a web service which sends pdf files to client as the client calls this web service.
请有人用好的代码或解释帮助我。
现在有人可以解决我的错误吗。
12-23 09:42:48.429: DEBUG/installd(32): DexInv: --- BEGIN '/data/app/vmdl33143.tmp' --- 12-23 09:42:51.708: DEBUG/dalvikvm(328): DexOpt: 'Lorg/xmlpull/v1/XmlPullParser;' has an earlier definition; blocking out
12-23 09:42:51.730: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/io/KXmlParser;' has an earlier definition; blocking out
12-23 09:42:51.749: DEBUG/dalvikvm(328): DexOpt: 'Lorg/xmlpull/v1/XmlSerializer;' has an earlier definition; blocking out
12-23 09:42:51.759: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/io/KXmlSerializer;' has an earlier definition; blocking out
12-23 09:42:51.779: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/kdom/Node;' has an earlier definition; blocking out
12-23 09:42:51.779: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/kdom/Document;' has an earlier definition; blocking out
12-23 09:42:51.819: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/kdom/Element;' has an earlier definition; blocking out
12-23 09:42:51.830: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/wap/Wbxml;' has an earlier definition; blocking out
12-23 09:42:51.840: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/wap/WbxmlParser;' has an earlier definition; blocking out
12-23 09:42:51.900: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/wap/WbxmlSerializer;' has an earlier definition; blocking out
12-23 09:42:51.910: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/wap/syncml/SyncML;' has an earlier definition; blocking out
12-23 09:42:51.910: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/wap/wml/Wml;' has an earlier definition; blocking out
12-23 09:42:51.929: DEBUG/dalvikvm(328): DexOpt: 'Lorg/kxml2/wap/wv/WV;' has an earlier definition; blocking out
12-23 09:42:51.929: DEBUG/dalvikvm(328): DexOpt: 'Lorg/xmlpull/v1/XmlPullParserException;' has an earlier definition; blocking out
12-23 09:42:51.949: DEBUG/dalvikvm(328): DexOpt: 'Lorg/xmlpull/v1/XmlPullParserFactory;' has an earlier definition; blocking out
12-23 09:42:53.299: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
12-23 09:42:53.319: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
12-23 09:42:53.329: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
12-23 09:42:53.350: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
12-23 09:42:53.350: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
12-23 09:42:53.370: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
12-23 09:42:53.499: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
12-23 09:42:53.560: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser;'
12-23 09:42:53.570: INFO/dalvikvm(328): DexOpt: not resolving ambiguous class 'Lorg/kxml2/io/KXmlSerializer;'
12-23 09:42:53.659: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/xmlpull/v1/XmlPullParser;': multiple definitions
12-23 09:42:53.668: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/io/KXmlParser;': multiple definitions
12-23 09:42:53.668: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/xmlpull/v1/XmlSerializer;': multiple definitions
12-23 09:42:53.668: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/io/KXmlSerializer;': multiple definitions
12-23 09:42:53.680: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/kdom/Node;': multiple definitions
12-23 09:42:53.690: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/kdom/Document;': multiple definitions
12-23 09:42:53.709: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/kdom/Element;': multiple definitions
12-23 09:42:53.709: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/wap/Wbxml;': multiple definitions
12-23 09:42:53.719: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/wap/WbxmlParser;': multiple definitions
12-23 09:42:53.719: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/wap/WbxmlSerializer;': multiple definitions
12-23 09:42:53.719: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/wap/syncml/SyncML;': multiple definitions
12-23 09:42:53.719: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/wap/wml/Wml;': multiple definitions
12-23 09:42:53.719: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/kxml2/wap/wv/WV;': multiple definitions
12-23 09:42:53.719: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/xmlpull/v1/XmlPullParserException;': multiple definitions
12-23 09:42:53.719: DEBUG/dalvikvm(328): DexOpt: not verifying 'Lorg/xmlpull/v1/XmlPullParserFactory;': multiple definitions
12-23 09:42:53.829: DEBUG/dalvikvm(328): DexOpt: load 867ms, verify 1752ms, opt 108ms
12-23 09:42:54.029: DEBUG/installd(32): DexInv: --- END '/data/app/vmdl33143.tmp'(success) ---
这是android模拟器DDMS的错误。
现在我的网络服务和代码如下所示。
代码:-
package com.uks.webservice;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.rmi.Remote;
public interface SendPDF extends Remote {
public String[] sendPDF() throws FileNotFoundException, IOException,
Exception;
}
Web 服务的主类已创建:-
package com.uks.webservice;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import sun.misc.BASE64Encoder;
public class SendPDFImpl implements SendPDF {
@Override
public String[] sendPDF() {
String[] pdfFile = new String[2];
BASE64Encoder encoder = new BASE64Encoder();
File file = new File(
"C:/eclipse/workspace/AIPWebService/src/test.pdf");
DataHandler dh = new DataHandler(new FileDataSource(file));
String readLine = null;
byte[] data = new byte[(int) file.length()];
int offset = 0;
int numRead = 0;
InputStream stream = null;
try {
System.out.println("Web Service Called Successfully");
stream = dh.getInputStream();
// BufferedReader bufferedReader = new BufferedReader(
// new InputStreamReader(stream));
while (offset < data.length
&& (numRead = stream.read(data, offset, data.length
- offset)) >= 0) {
offset += numRead;
}
readLine = encoder.encode(data);
// while ((readLine = bufferedReader.readLine()) != null) {
System.out.println("'Reading File............................");
System.out.println("\n");
System.out.println("Data Reading Successful");
pdfFile[0] = file.getName();
pdfFile[1] = readLine;
stream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return pdfFile;
}
}
网络服务:-
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://webservice.uks.com"
xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.uks.com"
xmlns:intf="http://webservice.uks.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--
WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006
(06:55:48 PDT)
-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://webservice.uks.com"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="sendPDF">
<complexType />
</element>
<element name="sendPDFResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="sendPDFReturn" type="xsd:String" />
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="sendPDFRequest">
<wsdl:part element="impl:sendPDF" name="parameters" />
</wsdl:message>
<wsdl:message name="sendPDFResponse">
<wsdl:part element="impl:sendPDFResponse" name="parameters" />
</wsdl:message>
<wsdl:portType name="SendPDFImpl">
<wsdl:operation name="sendPDF">
<wsdl:input message="impl:sendPDFRequest" name="sendPDFRequest" />
<wsdl:output message="impl:sendPDFResponse" name="sendPDFResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SendPDFImplSoapBinding" type="impl:SendPDFImpl">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sendPDF">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="sendPDFRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="sendPDFResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SendPDFImplService">
<wsdl:port binding="impl:SendPDFImplSoapBinding" name="SendPDFImpl">
<wsdlsoap:address
location="http://localhost:8080/AIPWebService/services/SendPDFImpl" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
现在是我的 Android 代码。
package com.uks.android.webservice;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
public class PDFActivity extends Activity {
private final String METHOD_NAME = "sendPDF";
private final String NAMESPACE = "http://webservice.uks.com/";
private final String SOAP_ACTION = NAMESPACE + METHOD_NAME;
private final String URL = "http://192.168.1.123:8080/AIPWebService/services/SendPDFImpl";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textViewOne = (TextView) findViewById(R.id.textViewOne);
TextView textViewTwo = (TextView) findViewById(R.id.textViewTwo);
try {
SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(soapObject);
textViewOne.setText("Web Service Started");
AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
httpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.getResponse();
textViewTwo.setText(result.toString());
// Object result = envelope.getResponse();
// FileOutputStream outputStream = openFileOutput(name, mode)
} catch (Exception e) {
e.printStackTrace();
}
}
}
请帮帮我。
提前致谢。
最佳答案
您需要将文件转换为字节数组并将其传递给服务器上的服务,执行相反的操作以取回文件。
关于java - 通过Web服务从服务器向客户端发送pdf文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4507201/
我的代码有一些问题。我正在尝试遍历包含许多 PDF 的 Drive 文件夹,然后将它们合并为一个文件。当我使用我的代码时,它只是为 Drive 文件夹中的最后一个 PDF 创建一个 PDF,而不是按预
我从 PDF Specification 获取了 PDF 规范中的最小 PDF 示例。 ,将其复制到记事本,将文件重命名为扩展名为 .pdf。 我可以用其他 PDF 查看器(PDF-XChange、S
感谢您在以下方面的帮助: 我有 2 个部分可访问的 PDF(包含标签),我想使用一些命令行工具(如 PDFtk 或 Ghostscript,或任何 Perl 模块)将它们连接起来: 我已经尝试使用 P
我想使用 ghostscript 将矢量 pdf 转换为光栅 pdf(即光栅化矢量 pdf)。但是即使我添加了解析参数 -r300,我也找不到合适的参数来执行此操作。 我使用的代码是-dSAFER -
我无法在 FAQ 中找到这个功能是否存在于 API 中,尽管它在书中提到作为潜在可用的东西。有没有人有任何实现此功能的经验? 最佳答案 在 This thread (日期为 2007 年 6 月)Pa
我要放文件sample.pdf在我的网站上,并希望使用 pdf.js 显示它.我想要的是显示我自己的文件,如 demo ,带有工具栏,放大/缩小等。到目前为止,我还不能这样做。 我确实检查了 hell
我知道这可能不是严格意义上的编程问题(也许是,我不知道)但我在尝试转换常规 pdf(带有超链接、书签、图像、嵌入字体等)时遇到了严重问题.) 转换为 PDF/A-1 格式。 当我用 pdfaPilot
这是 PDF.js 网站 https://github.com/mozilla/pdf.js 我正在搜索和阅读很多文章,大多数编码都是将 pdf 导入 pdf.js 并在浏览器上显示,我不明白是不是
谁能建议我如何将扫描图像转换为可搜索图像或如何将扫描 pdf 转换为可搜索 pdf? 很长一段时间以来,我一直陷入这种情况。 我已经在 ubuntu 中尝试过 pdfocr 应用程序,但没有成功。 最
作为我对客户端/服务器 pdf 签名研究的一部分,我测试了 itext pdf 延迟签名示例。不幸的是,我生成的 pdf 即合并空签名 pdf 和哈希值的输出显示无效签名。 我的代码片段如下 cla
我想将一个 PDF 页面插入到另一个已缩放的 PDF 页面中。我想使用 iTextSharp 来实现此目的。 我有一个矢量绘图,可以导出为单页 PDF 文件。我想将此文件添加到其他 PDF 文档的页面
作为我对客户端/服务器 pdf 签名研究的一部分,我测试了 itext pdf 延迟签名示例。不幸的是,我生成的 pdf 即合并空签名 pdf 和哈希值的输出显示无效签名。 我的代码片段如下 cla
我想为 Kindle 转换电子书。我尝试使用 Calibre 将具有复杂格式样式和图像的基于两种语言的基于文本的大型 PDF 电子书转换为适用于 Kindle 的 AZW3 电子书,并且还尝试了亚马逊
我在 Google Chrome 中显示 pdf 时遇到问题。问题是 Chrome 将 pdf 的某些页面显示为黑色。 启用 Chrome PDF 查看器时会发生这种情况。如果我禁用此插件并使用 Ad
我确信这个问题无处不在,尽管我似乎找不到答案。我希望我的 PDF 文档在 PDF 阅读器中显示时没有空白页,但随后在封面后打印空白页,这样打印出来的文档在右侧甚至左侧都有奇数页。还有其他人遇到过这个问
我需要自动裁剪 pdf 文件(去除白边)。到目前为止,我尝试了两种并不完美的工具: pdf裁剪 问题:它不会裁剪某些 pdf。 pdf-crop-margins 问题:有时它裁剪得太多(精细的细节)。
This PDF由几个源文件组成。其中五个是包含 alpha channel 的 PNG。一种是没有 alpha channel 的 PNG。最后一 block 是带有透明效果的 Photoshop
我的团队将内部 wiki 页面用于各种内容。这些页面是使用 MediaWiki 创建的。我想知道是否有任何方法可以将 wiki 页面转换为 PDF 格式。我必须用它来将用户文档转换为 PDF 格式,以
我希望能够从我可能在数据库或 xml 或任何其他结构化形式中拥有的数据生成高度图形化(也包含大量文本内容)的 PDF 文件。 目前,我们的平面设计师在将内容作为 MS Word 文档后,在 Photo
我正在寻找可以帮助我找到重复 PDF 的实用程序。问题:我有 1000 个 PDF 文件。有些是重复的。由于不同的文件名和文件大小的微小差异,它们不容易被检测到。是否有实用程序/算法/库可以帮助我找到
我是一名优秀的程序员,十分优秀!