如何从 DataHandler 获取 mime 数据
我使用 Axis2 的 MTOM 发送一条肥皂消息,并监视肥皂得到以下消息:
--MIMEBoundaryurn_uuid_5C5747FDE5329B8CEB1280130156514
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:[email protected]>
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:EventMessage xmlns:ns1="http://www.iec.ch/TC57/2008/schema/message"><ns1:Header><ns1:Verb>created</ns1:Verb><ns1:Noun>NetwordDataSet</ns1:Noun></ns1:Header><ns1:Payload><ns1:Compressed><xop:Include href="cid:1.urn:uuid:[email protected]" xmlns:xop="http://www.w3.org/2004/08/xop/include" /></ns1:Compressed><ns1:format>RDF</ns1:format></ns1:Payload></ns1:EventMessage></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_5C5747FDE5329B8CEB1280130156514
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <1.urn:uuid:[email protected]>
测试一把
1
2
3
4
5
--MIMEBoundaryurn_uuid_5C5747FDE5329B8CEB1280130156514--
在服务器端,我使用代码生成工具获取了代码,但 dataHandler 为空。代码是这样的:
public void publishEvent
(
ch.iec.www.tc57._2008.schema.message.EventMessage eventMessage
)
throws FaultMessage{
//TODO : fill this with the necessary business logic
EventMessageType emt = eventMessage.getEventMessage();
PayloadType plt = emt.getPayload();
DataHandler dataHandler = plt.getPayloadTypeChoice_type0().getCompressed();
if(dataHandler!=null){....}
}
我修复了它。
这是关于我的 XSD
<xs:choice>
<xs:any namespace="##other" processContents="skip" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>For XML payloads</xs:documentation>
</xs:annotation>
</xs:any>
<xs:element name="Compressed" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>For compressed and/or binary, uuencoded payloads</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
当我删除 XSD 的
部分时,我可以获得 dataHandler。不支持?
I send a soap message using MTOM by Axis2, and i monitor the soap get the message below:
--MIMEBoundaryurn_uuid_5C5747FDE5329B8CEB1280130156514
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:[email protected]>
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:EventMessage xmlns:ns1="http://www.iec.ch/TC57/2008/schema/message"><ns1:Header><ns1:Verb>created</ns1:Verb><ns1:Noun>NetwordDataSet</ns1:Noun></ns1:Header><ns1:Payload><ns1:Compressed><xop:Include href="cid:1.urn:uuid:[email protected]" xmlns:xop="http://www.w3.org/2004/08/xop/include" /></ns1:Compressed><ns1:format>RDF</ns1:format></ns1:Payload></ns1:EventMessage></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_5C5747FDE5329B8CEB1280130156514
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <1.urn:uuid:[email protected]>
测试一把
1
2
3
4
5
--MIMEBoundaryurn_uuid_5C5747FDE5329B8CEB1280130156514--
In the server side i got the code using code generation tools, but the dataHandler is null. And the code like this:
public void publishEvent
(
ch.iec.www.tc57._2008.schema.message.EventMessage eventMessage
)
throws FaultMessage{
//TODO : fill this with the necessary business logic
EventMessageType emt = eventMessage.getEventMessage();
PayloadType plt = emt.getPayload();
DataHandler dataHandler = plt.getPayloadTypeChoice_type0().getCompressed();
if(dataHandler!=null){....}
}
I fixed it.
It's about my XSD
<xs:choice>
<xs:any namespace="##other" processContents="skip" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>For XML payloads</xs:documentation>
</xs:annotation>
</xs:any>
<xs:element name="Compressed" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>For compressed and/or binary, uuencoded payloads</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
When i delete the <xs:choice>
portion of the XSD, i can get the dataHandler. not supported?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论