如何从 DataHandler 获取 mime 数据

发布于 2024-09-11 13:21:50 字数 3095 浏览 5 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文