All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: About Question enthuware.ocejws.v6.2.154 :
PostPosted: Wed Jul 20, 2016 5:02 am 
Offline

Joined: Tue Sep 08, 2015 3:27 am
Posts: 14
Hi.

Could you please explain this option, I couldn't find any references in the internet
Quote:
"By doing nothing:  if the server WSDL advertises that it supports MTOM, the MTOM support in the client will be automatically enabled."


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocejws.v6.2.154 :
PostPosted: Thu Jul 21, 2016 2:08 pm 
Offline

Joined: Tue Jul 24, 2012 2:43 am
Posts: 401
Hi Igor,

This is implicit. JAX-WS v2.x says: "Enabling this feature on either the server or client will result the JAX-WS runtime using MTOM and for binary data being sent as an attachment."

If the WSDL does have a ws-policy assertion stating that MTOM is enabled, the related WebService has an MTOM annotation. The client in that case does not have to explicitly enable MTOM again.

The following code example will hopefully help you understand. Let's say we have this WebService on the server-side:
Code:
@MTOM
public class GifServiceImpl implements GifService {
   @Override
   public Image getGifImage(String name) {
      BufferedImage img = null;
      try {
         System.out.println("getting image: " + name);
         img = ImageIO.read(new File(name));
      } catch (IOException e) {
         System.out.println("image not found");
      }
      return img;
   }
}

The WSDL being published is then:
Code:
<definitions ... left out ...>
<wsp:Policy wsu:Id="GifServiceImplPortBinding_MTOM_Policy-GifServiceImplPortBinding_MTOM_Policy">
   <ns1:OptimizedMimeSerialization xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>
</wsp:Policy>
 ... left out ...
</portType>
<binding name="GifServiceImplPortBinding" type="tns:GifService">
  <wsp:PolicyReference URI="#GifServiceImplPortBinding_MTOM_Policy-GifServiceImplPortBinding_MTOM_Policy"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
 <operation name="getGifImage">
  <soap:operation soapAction=""/>
     <input>
        <soap:body use="literal"/>
     </input>
     <output>
        <soap:body use="literal"/>
      </output>
  </operation>
</binding>
  ... left out ...
</definitions>

The Client code (without enabling MTOM, but still you will get the image as an attachment)
Code:
public class GifServiceClient {
   public static void main(String[] args) throws IOException {
      GifServiceImplService service = new GifServiceImplService();
      GifService port = service.getPort(GifService.class);
      Image gifImage = port.getGifImage("rssLogo.gif");
      ImageIO.write((RenderedImage) gifImage, "gif", new File("receivedLogo.gif"));
   }
}


Does this answer your question?

Regards,
Frits


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocejws.v6.2.154 :
PostPosted: Sat Jul 23, 2016 2:46 am 
Offline

Joined: Tue Sep 08, 2015 3:27 am
Posts: 14
Thank you.


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocejws.v6.2.154 :
PostPosted: Mon Jan 02, 2017 1:26 pm 
Offline

Joined: Wed Jan 20, 2016 7:16 pm
Posts: 12
fjwalraven wrote:
Hi Igor,

This is implicit. JAX-WS v2.x says: "Enabling this feature on either the server or client will result the JAX-WS runtime using MTOM and for binary data being sent as an attachment."

If the WSDL does have a ws-policy assertion stating that MTOM is enabled, the related WebService has an MTOM annotation. The client in that case does not have to explicitly enable MTOM again.

The following code example will hopefully help you understand. Let's say we have this WebService on the server-side:
Code:
@MTOM
public class GifServiceImpl implements GifService {
   @Override
   public Image getGifImage(String name) {
      BufferedImage img = null;
      try {
         System.out.println("getting image: " + name);
         img = ImageIO.read(new File(name));
      } catch (IOException e) {
         System.out.println("image not found");
      }
      return img;
   }
}

The WSDL being published is then:
Code:
<definitions ... left out ...>
<wsp:Policy wsu:Id="GifServiceImplPortBinding_MTOM_Policy-GifServiceImplPortBinding_MTOM_Policy">
   <ns1:OptimizedMimeSerialization xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>
</wsp:Policy>
 ... left out ...
</portType>
<binding name="GifServiceImplPortBinding" type="tns:GifService">
  <wsp:PolicyReference URI="#GifServiceImplPortBinding_MTOM_Policy-GifServiceImplPortBinding_MTOM_Policy"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
 <operation name="getGifImage">
  <soap:operation soapAction=""/>
     <input>
        <soap:body use="literal"/>
     </input>
     <output>
        <soap:body use="literal"/>
      </output>
  </operation>
</binding>
  ... left out ...
</definitions>

The Client code (without enabling MTOM, but still you will get the image as an attachment)
Code:
public class GifServiceClient {
   public static void main(String[] args) throws IOException {
      GifServiceImplService service = new GifServiceImplService();
      GifService port = service.getPort(GifService.class);
      Image gifImage = port.getGifImage("rssLogo.gif");
      ImageIO.write((RenderedImage) gifImage, "gif", new File("receivedLogo.gif"));
   }
}


Does this answer your question?

Regards,
Frits


Hi,

I'm a bit confused here, why is client able to consume Image type directly from web service? Isn't it returned as byte[] unless web service (SEI) uses @XmlMimeType annotation or adds xmime:expectedContentType in XSD as per question (enthuware.ocejws.v6.2.130) Am I missing something?

Thanks,
Victor.


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocejws.v6.2.154 :
PostPosted: Mon Jan 02, 2017 2:15 pm 
Offline

Joined: Tue Jul 24, 2012 2:43 am
Posts: 401
Hi Victor,

With the MTOM Feature the binary data is sent in it's original form as an attachment. There is no base64 encoding/decoding taking place.

Regards,
Frits


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Template made by DEVPPL/ThatBigForum