Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
java
java
@XmlType
public class Picture {
  private String title;

  @XmlMimeType("application/octet-stream")
  private DataHandler imageData;

  public String getTitle() { return title; }
  public void setTitle(String title) { this.title = title; }

  public DataHandler getImageData() { return imageData; }
  public void setImageData(DataHandler imageData) { 
     this.imageData = imageData; }
}

...

Code Block
java
java
import javax.xml.ws.Endpoint;
import javax.xml.ws.soap.SOAPBinding;

Endpoint ep = Endpoint.publish("http://localhost/myService", 
   new MyService());
SOAPBinding binding = (SOAPBinding) ep.getBinding();
binding.setMTOMEnabled(true);

...

Code Block
xml
xml
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
   http://cxf.apache.org/jaxws
   http://cxf.apache.org/schema/jaxws.xsd">

  <jaxws:endpoint 
    id="helloWorld" 
    implementor="demo.spring.HelloWorldImpl" 
    address="http://localhost/HelloWorld">
    <jaxws:properties>
      <entry key="mtom-enabled" value="true"/>
    </jaxws:properties>
  </jaxws:endpoint>

</beans>

...

Code Block
java
java
Map<String,Object> props = new HashMap<String, Object>();
props.put("mtom-enabled", Boolean.TRUE); // Boolean.TRUE or "true" will work as the property value herebelow
props.put("mtom-enabled", Boolean.TRUE); 

ClientProxyFactoryBean pf = new ClientProxyFactoryBean();
pf.setPropertyies(props);
....
YourClient client = (YourClient) pf.create();

ServerFactoryBean sf = new ServerFactoryBean();
sf.setPropertyies(props);
...
sf.create();

...

Code Block
xml
xml
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:simple="http://cxf.apache.org/simple"
	xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/simple 
http://cxf.apache.org/schema/simple.xsd">

  <simple:server
    id="helloWorld" 
    serviceClass="demo.spring.HelloWorldImpl" 
    address="http://localhost/HelloWorld">
    <simple:properties>
      <entry key="mtom-enabled" value="true"/>
    </simple:properties>
  </simple:server>

  <simple:client
    id="helloWorldClient" 
    serviceClass="demo.spring.HelloWorldImpl" 
    address="http://localhost/HelloWorld">
    <simple:properties>
      <entry key="mtom-enabled" value="true"/>
    </simple:properties>
  </simple:client>

</beans>

...

Code Block
java
java
DataSource source = new ByteArrayDataSource(new byte[] {...},
   "content/type");
DataSource source = new FileDataSource(new File("my/file"));

Picture picture = new Picture();
picture.setImageData(new DataHandler(source));