- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
基本上我想创建一个 Web 服务客户端以通过代理方法发送 mtom soap 消息。我已经通过 Web 服务 wsdl 创建了我的服务工件。消息已正确创建,但是当我启用 mtom 并添加附件时,附件始终以内联方式发送,而不是在单独的 mime 部分中发送。它类似于 mtom 已启用,但由于某种原因,它决定不优化消息,因此将其内联发送。通过 soapui 运行相同的代码会给出正确的结果,所以我知道服务本身会接受它。
这是我创建 soap 请求并发送它的基本代码。我启用了 mtomfeature,但也尝试过使用 soapBinding.setMTOMEnabled(true);
对于这两种方法,我都使用 ((SOAPBinding) binding).isMTOMEnabled()
对其进行了调试,以检查它是否已设置为启用。
// initiate services....
// create service and enable mtom
WebServiceBlah service = new WebServiceBlah(new URL(wsdlURL), SERVICE_NAME);
WebServiceBlahPort port = service.getWebServiceBlahPort(new MTOMFeature(true, 3072));
// load file
File file = new File("/home/mypdf.pdf");
FileInputStream fileinputstream = new FileInputStream(file);
int numberBytes = fileinputstream.available();
byte bytearray[] = new byte[numberBytes];
fileinputstream.read(bytearray);
fileinputstream.close();
// create uploadResult
UploadResult request = new UploadResult();
// create attachment
AttachmentType attachment = new AttachmentType();
attachment.setContentType("application/doc");
attachment.setValue(bytearray);
// create result and add attachment to it
RenderedResult result = new RenderedResult();
result.setResult(attachment);
result.setResultContentType("pdf");
result.setResultName("a pdf file");
// add result to request
request.getResult().add(result);
// send request
port.UploadResults(request);
我得到的是我的附件是在线发送的,如下所示。 (用wireshark捕获)
POST /blah/ws/ HTTP/1.1
Content-type: multipart/related;start="<rootpart*15c3ee3b-60c7-4726-a52c-8080965e4536@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:15c3ee3b-60c7-4726-a52c-8080965e4536";start-info="text/xml"
Soapaction: ""
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JAX-WS RI 2.1.6 in JDK 6
Host: 123.123.123.123
Connection: keep-alive
Content-Length: 12372
--uuid:15c3ee3b-60c7-4726-a52c-8080965e4536
Content-Id: <rootpart*15c3ee3b-60c7-4726-a52c-8080965e4536@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header></S:Header>
<S:Body>
<ns2:uploadResult xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<renderedResult>
<result xmime:contentType="application/doc">JVBERi0xLjQKJaqrrK0KNCAwIG9iago8</result>
<resultContentType>pdf</resultContentType>
<resultName>a pdf file</resultName>
</renderedResult>
</ns2:uploadResult>
</S:Body>
</S:Envelope>
--uuid:15c3ee3b-60c7-4726-a52c-8080965e4536
我想要的是将结果标记中的附件替换为内联标记,并将附件添加到不同 mime 部分的 soap 消息中。例如
<result xmime:contentType='application/doc'>
<inc:Include href="cid:myid3" xmlns:inc='http://www.w3.org/2004/08/xop/include'/>
</result>
然后将以下内容添加到 soap 消息中
------=_Part_10_28027205.1314348995670
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: cid:myid3
Content-Disposition: attachment; name="mypdf.pdf"
JVBERi0xLjQKJaqrrK0KNCAwIG9iago8
最佳答案
许多因素会影响 MTOM 附件是否被实际使用。
在服务器上,首先是显而易见的:检查您的服务实现是否具有 @MTOM
注释。您还可以使用 threshold()
属性从此注释调整阈值(正如 SteveJ 已经提到的那样)。
有时服务器上的处理程序会干扰是否使用 MTOM 附件。任何将 SOAP 消息序列化为字符串或字节数组的处理程序(通常用于将消息内容写入日志的调试样式处理程序)将阻止使用 MTOM 附件。如果可能,请尝试禁用您的处理程序链并查看 MTOM 附件是否在此之后通过。
关于java - JAX-WS 始终内联发送 MTOM 附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7202410/
我们有一个非常简单的 WS,使用注释实现。我们希望能够从支持和不支持 MTOM/XOP 的客户端调用它。现在,它被简单地注释为@MTOM。 它接受包含(除其他外)base64Binary 元素的请求,
MTOM 是 W3C 消息传输优化机制,是一种高效地向 Web 服务发送二进制数据或从 Web 服务发送二进制数据的方法。 一般来说它是如何工作的? 最佳答案 这一切都始于 SOAP 是XML这一事实
我刚刚开始使用 SOAP Web 服务,偶然发现了 MTOM。 根据以下用例,我需要了解两件事:用户将通过传递图像来调用 SOAP Web 服务。作为响应,他们将获得同一图像的格式化版本。 我知道我需
如何配置自定义绑定(bind)和 MTOM 编码?我有一个自定义绑定(bind),如下所示,
我必须使用外部 Web 服务,但出现以下错误: The maximum buffer size (65536) has been exceeded while reading MTOM data 在今
我一直在使用一些代码通过使用来自 MSDN 的代码来创建 MTOM . 好像有错误,我不明白问题出在哪里,因为论坛上的一位用户指出有错误。 文件 (JPEG) 数据在反序列化后损坏。完整代码如下。
我有以下 mtom 响应作为字符串 --uuid:6b6fab3b-c481-4648-9eb5-8690096eb54d Content-Type: application/xop+xml; cha
作为我的 worklight 项目的一部分,我们正在调用一个 Web 服务,该服务将图像文件作为 MTOM 附件发送。有没有办法解析图像内容并转换为 JSON 对象?下面是我配置服务调用的适配器中的一
我正在尝试制作一个非常简单的网络服务,它执行以下操作: 客户端点击网络服务请求文件。 Web 服务的服务类查询一个哈希表,该哈希表具有键(搜索查询)和值作为文件(例如 pdf)的 base64 编码值
Java XML 验证是否支持启用了 MTOM 的消息?验证期间抛出以下错误。 cvc-type.3.1.2: Element 'ns2:myblobData' is a simple type, s
我正在使用 MTOM 将附件从客户端流式传输到服务器。 MTOM 得到应用,文件以二进制形式流式传输。但是根 Content-Type 始终是 "text/xml",应该是 "application/
SAAJ: SOAP with Attachments API for Java MTOM: SOAP消息传输优化机制 我的简单理解:它们处理 SOAP 附件,MTOM 是 SAAJ 的更优化版本。它
我正在寻找使用 JAX-WS RI 或基于 Axis2 的简单、有效的示例 MTOM 示例代码(服务 + 客户端)。 我在 google 上搜索这个词只是为了找到不能简单工作的片段和代码! 我想将 P
我们的应用程序使用 SOAP 将文件附件发送到 Web 服务。该服务在 Oracle Service Bus 11g 上运行。我们在客户端使用Spring WS + SAAJ + MTOM来发送请求。
我们有一个用例,我们必须通过 http 将大数据文件从环境 A 传输到环境 B。我们想要实现的是,发送方将数据分块发送,接收方开始将数据分块写入文件。因此我们决定使用 MTOM。 网络服务代码: @M
我将在早上用代码示例更新此内容,但我有一个基本的 JAX-WS 实现,用于通过 MTOM 下载生成的文件,并且当我在 SOAPUI 中测试它时附加的文件甚至有一个随机文件名尽管我传递给 DataHan
我正在尝试做非常简单的事情:客户端通过其 WSDL 调用 SOAP 服务来加载 PDF 文档。 我正在使用 Apache CXF 2.7.5 和 MTOM 问题是文档似乎没有完全发送到客户端(文件大小
对于一个项目,我正在使用 Apache Axis2 1.6.2 实现 SOAP 服务。我有一项服务需要使用 MTOM 接收文件。但遗憾的是我在接收 MTOM 附加文件时一直遇到问题。我不断收到异常:
我在 Java 1.6 中使用 JAX-WS 的引用实现。在我的服务器上,我有 Web 服务方法,它返回一个带有附件作为 javax.activation.DataHandler 的响应。 File
这是我已经回答过的那些“问题”之一,但是根据一周的谷歌搜索,我发布的信息似乎几乎为零。 TL;DR:WCF MTOM 编码的 BasicHttpBinding 客户端到外部/第三部分,非 .NET W
我是一名优秀的程序员,十分优秀!