Announcement Announcement Module
Collapse
No announcement yet.
Spring-WS with attachment Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring-WS with attachment

    Hi,

    I have a spring ws client and would like to be able to attach and attachment to the request and submit it to an spring ws server. I would like the request to include the file as an Mime attachment. I think the request should look something like this:

    Content-Type: multipart/related; boundary=MIMEBoundary4A7AE55984E7438034;
    type="application/xop+xml"; start="<[email protected]>";
    start-info="text/xml; charset=utf-8"

    --MIMEBoundary4A7AE55984E7438034
    content-type: application/xop+xml; charset=utf-8; type="application/soap+xml;"
    content-transfer-encoding: binary
    content-id: <[email protected]>

    <?xml version='1.0' encoding='utf-8'?>
    <soapenv:Envelope xmlns:soapenv="...."....>
    ........
    <xop:Include href="cid:[email protected]"
    xmlns:xop="http://www.w3.org/2004/08/xop/include">
    </xop:Include>
    ........

    But right now it looks like:

    "Accept-Encoding: gzip[\r][\n]"
    "Accept: application/soap+xml[\r][\n]"
    "Content-Type: application/soap+xml; charset=UTF-8; action=""[\r][\n]"
    "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]"
    "Host: localhost:8082[\r][\n]"
    "Content-Length: 11842817[\r][\n]"
    "[\r][\n]"
    "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:s

    and the attachment is inline.

    Here's is my xsd:

    <xs:complexType name="Attachment">
    <xs:sequence>
    <xs:element name="name" type="xs:string" />
    <xs:element name="file" type="xs:base64Binary"
    xmime:expectedContentTypes="application/octet-stream"/>
    </xs:sequence>
    </xs:complexType>

    My client config:

    <bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoap MessageFactory">
    <property name="soapVersion">
    <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOA P_12" />
    </property>
    <property name="attachmentCaching" value="true" />
    </bean>

    <bean id="serviceMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
    <property name="contextPath" value="epost.mojito.wsc.wsdl" />
    <property name="mtomEnabled" value="true" />
    </bean>

    <bean id="clientTemplate" class="org.springframework.ws.client.core.WebServi ceTemplate">
    <constructor-arg ref="messageFactory" />
    <property name="marshaller" ref="serviceMarshaller"></property>
    <property name="unmarshaller" ref="serviceMarshaller"></property>
    <property name="messageSender">
    <bean class="org.springframework.ws.transport.http.Commo nsHttpMessageSender">
    </bean>
    </property>
    <property name="defaultUri" value="http://localhost:8082/mojito-ws/" />
    </bean>

    I'm not sure what else am I missing?

    Thanks in advance.
    Last edited by bdo; Jul 13th, 2012, 12:29 AM.
Working...
X