Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:52:49+00:00 2026-06-07T17:52:49+00:00

I have a Spring-WS web service where i would like to be able to

  • 0

I have a Spring-WS web service where i would like to be able to send back binary data to the client. My intention is to format the SOAP response to either use MTOM or Soap with attachements. The response will be a JAXB object.

I have already setup the Spring-WS environment and can send and receive requests usign JAXB. I am however struggling to setup the Binary attachement response as most of the tutorials and information on the web are mostly related to Clients sending attachements whereas i am interested in Server sending attachements back to the client.

Two questions:

  • Which is the recommended approach for returning binary data to the client? SOAP with attachements, MTOM or just simply return the base64encoded data as an xml tag?

  • Are there any examples that shows how to configure Spring-WS to return Binary attachments using either of the two methods?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:52:51+00:00Added an answer on June 7, 2026 at 5:52 pm

    1)
    Mtom is apparently the de-facto standard for sending files via soap, so i would recommend that.

    2)
    if you look at the mtom example that comes with the spring-ws distrobution (not from maven) you will see 90% of the setup required. the one difference is the expectedContentType for your attachment you should set that to application/octet-stream

    now your code on the server will look something like this

    try {
            dataHandler = new DataHandler(new File("/tmp/test.exe").toURL());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        return new JaxbObjectResponse("id", dataHandler);
    

    and your schema definition looks something like this.

    <xsd:element name="JaxbObjectResponse">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="id" type="xsd:string" />
                <xsd:element name="file" type="xsd:base64Binary" xmime:expectedContentTypes="application/octet-stream" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spring roo web service that I am currently building out but
I have a spring-based Web Service. I now want to build a sort of
I have a web service written in Spring MVC. It can be used by
I'm using spring ws 2.0.2.RELEASE I have a web service that creates a sales
I have web service which return json string like : d={main0ID:abc.es/main,main1ID:ah/main} I wanna append
I have a web service that is processed on the Spring end as follows:
I have Camel route that I would like to expose as a REST Web
I have a RESTful web service that returns JSON-serialized data. It can successfully serialize
Is there any way to consume a SOAP based Spring web service without generating
I have implement a web service using jersey and I have a client making

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.