首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JAX-WS MTOM或BindingType标注

JAX-WS MTOM或BindingType标注
EN

Stack Overflow用户
提问于 2017-11-08 20:50:14
回答 1查看 467关注 0票数 0

在理解JAX-WS服务中的MTOM概念时,我有点困惑。我有一个have服务,它公开了一个返回Image的方法。下面是SIB和publisher代码

代码语言:javascript
复制
//@MTOM
@WebService(endpointInterface= "com.test.clear.TestImageInterface")
@BindingType(value = SOAPBinding.SOAP11HTTP_MTOM_BINDING)
public class TestImageImpl implements TestImageInterface{


@WebMethod
@Override
// Create a named image from the raw bytes.
public Image getImageByName(String name) {

    Path path = Paths.get("..\..\..\"+name);

try {

    byte[ ] bytes = Files.readAllBytes(path);
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    Iterator iterators = ImageIO.getImageReadersByFormatName("jpeg");
    ImageReader iterator = (ImageReader) iterators.next();
    ImageInputStream iis = ImageIO.createImageInputStream(in);
    iterator.setInput(iis, true);
    return iterator.read(0);
}
catch(IOException e) {
    System.err.println(e);
return null;
}
}

}

publisher >>

代码语言:javascript
复制
Endpoint.publish("http://localhost:8080/TestWS/getImage", new TestImageImpl());

我的困惑是理解什么时候使用@MTOM,什么时候使用@BindingType注释。如果我使用其中一个注解或同时使用两个注解,我看不到publisher类发布的WSDL有什么不同。下面是生成的WSDL

代码语言:javascript
复制
<wsp:Policy wsu:Id="TestImageImplPortBinding_MTOM_Policy">
<ns1:OptimizedMimeSerialization xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>

代码语言:javascript
复制
<binding name="TestImageImplPortBinding" type="tns:TestImageInterface">
<wsp:PolicyReference URI="#TestImageImplPortBinding_MTOM_Policy"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>

...
...
</definitions>

另外,我也看不到从Service获取的SOAP响应有什么不同。ie:我得到了

代码语言:javascript
复制
 < Xop:include href:cid / >   and got file as attachment in 

这是否意味着在服务器端启用MTOM可以使用这两个注释中的任何一个?

在从SIB中删除两个注释后,我尝试在publisher端以编程方式设置MTOM,如下所示:

代码语言:javascript
复制
SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
binding.setMTOMEnabled(true);

但是,生成的WSDL根本没有MTOM策略。

那么,当需要以编程方式设置MTOM时呢?

有人能解释一下MIME类型和MTOM的工作原理吗?

提前谢谢你。

EN

回答 1

Stack Overflow用户

发布于 2017-11-09 15:35:10

我在这里得到了上述问题的答案>> [ http://itdoc.hitachi.co.jp/manuals/3020/30203Y2310e/EY230716.HTM ][

]1

谢谢大家。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47180203

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档