Doorgaan naar hoofdcontent

OSB 10gR3 and SWA and MTOM

This blog is about using soap with attachments and the use of MTOM within the OSB (10gR3).
A service is created that accepts a soap with attachment (DocumentService) and translates it to a service that accepts a binary element. MTOM is used for performance reasons for the second.

Some notes:
* For the use of attachments you need RPC-style document instead of the usual document-style. This due to the fact that the document-style limits a message to a single .
* A service can not have both SWA and MTOM within OSB.

First a WSDL is setup for the DocumentService:

  
    
    
     
      
       
        
       
      
     
     
    
  
  
  
    
    
  

  
    
      
    
  
  
  
    
    
      
      
       
         
           
         
         
           
         
       
      
    
  
  
  
    
      
    
  



The $attachments variable holds the attachments and the body holds the attachment data. Also other data is stored within the attachment element (see here). In the case of a binary attachment (as described within this post), this data is not put in the body element. Instead the Oracle Service Bus run time stores it in an in-memory hash table and a reference to that content is inserted into the XML (binary-content element).



Then you can use the OSB Test console to send an attachment and view the attachment variable.
After the attachment is sent, you can view the content of the attachments variable and it shows the binary reference.

Now the business service wsdl is defined and configured. The following WSDL is used.

  
    
    
     
      
       
        
        
       
      
     

    
  
  
  
    
  

  
    
      
    
  
  
  
    
    
      
      
  
   
    
  
  
  
    
      
    
  

We now define the business service that uses MTOM/XOP as transport protocol. Make a WSDL Web Service with the previous defined WSDL. In the transport properties just use http://localhost:7001/ecm as the endpoint, leave HTTP transport properties the default. In the Message Content you can set the MTOM/XOP enabling of the format. You have two possibilities (I will show both options). First select the "Include Binary Data by Value".


  • Include Binary Data by Reference: (Default) In an outbound response message, replace xop:Include elements with ctx:binary-content elements when setting up the $body message context variable.
  • Include Binary Data by Value: In an outbound response message, replace xop:Include elements with Base64-encoded text versions of corresponding binary data when setting up the $body message context variable.
Now we call this business service from within the proxy service.
Of course we have to map the document attachment to the bas64Binary element within the business service.
We add a Replace (Replace Node Contents) of the $body variable after the Assign.
If you run this within the test console with a Word attachment (Content-Type: application/word), you get the following invocation tree.
You see a binary-content reference, so you do not actually see what goes over the HTTP transport. Therefore you can use tcpmon which is a HTPP monitoring tool.
Run the tool and set it up by listening on port 8090. Click Add Monitor.

You also need to change the endpoint of the business service so that the message is sent to tcpmon.
Now run the test console again with an attachment. Now you probably get the following error.
It says that mixing attachments with XOP/MTOM is not allowed. This is due to the fact that we did not change the $attachments variable. You have to delete the attachments so we add a Delete after the Replace.
If you now run the test console again with an attachment the tcpmon tool we show you the actual http call and it will look something like this.
You can see that the Post is a application/xop+xml type and the Doc element contains a inc:Include reference.
The MIMI boundary contains the actual binary data.

Include Binary Data by Reference
Now change the Message Content configuration of the business service to Include Binary Data by Reference and run the test tool again. You will notice that in this case the result is the same.

Reacties

  1. alexander van der Woude31 augustus 2010 om 14:39

    Hey Roger,

    usefull article. Just what I needed.

    Chck your WSDL though, closing tags are located in wrong place.

    BeantwoordenVerwijderen
  2. Alexander,

    Good that I could help and thanks for the WSDL remark !

    BeantwoordenVerwijderen
  3. Hi Roger,
    thank you very much for your example.

    But I have found a problem with missing the start-info attribute in the Context-Type.

    Without this attribute called ASP.NET MTOM WS returns 400 Bad Request.

    BeantwoordenVerwijderen
  4. Hi Miloslav,
    Thanks for sharing this!

    In which part do you have to add start-info attribute?

    Thx
    Roger

    BeantwoordenVerwijderen
  5. There is the Content-Type with missing the start-info attribute in a business service. Also in your image from tcpmon.

    If there is no the start-info attribute the IIS(WSE) MTOM web service returns 400 Bad Request.
    I do not know how to add the attribute to the Content-Type.

    Currently I use an Any SOAP(with MTOM support) proxy that sends request with this attribute from client(SoupUI) and the proxy ONLY sends the request to a business service.
    It works.

    See my business service trace log.
    [OSB Tracing] Outbound request was sent.
    multipart/related; type="application/xop+xml"; start="<rootpart@soapui.org>"; start-info="text/xml"; boundary="----=_Part_1_6447144.1284621320422"

    BeantwoordenVerwijderen
  6. Maybe you can have a look at:
    http://blogs.oracle.com/mneelapu/2010/09/how_to_serve_html_through_osb.html

    Hope this can help you with changing the Content-Type.

    BeantwoordenVerwijderen
  7. Roger,

    Do you have an example to do this with bpel in a composite?

    Thank You.

    JP

    BeantwoordenVerwijderen
  8. Hello if this article is up to date? The WSDL are blanked. I am new to this and this example it is quite difficult to me withou proper WSDL.

    BeantwoordenVerwijderen
  9. From MTOM to SwA is possible, among proxies

    BeantwoordenVerwijderen
  10. Thanks!

    I had an issue and your article connected the DOTS.

    I also had blanked WSDL ... but the WSDL is not the answer to your issues.

    BeantwoordenVerwijderen

Een reactie posten

Populaire posts van deze blog

Microservices mindmap

"The tree" - See also   my photo page When you are fairly new within the Microservices land, there are a lot of terms fired at you. So also for my own understanding i have made a mindmap. I think it has a good status now, so that i can share it with you. As always feedback is very welcome ! You can download the mindmap here .

Installing Oracle SOA Suite/JDeveloper 11g

This post guides you through the installation of the Oracle SOA Suite 11g with JDeveloper 11 with the use of Oracle XE database (for Windows). Note: It is assumed that Oracle XE database is already installed. Required downloads Oracle Weblogic Server 10.3.1   SOA Suite   Repository Creation Utility JDeveloper Studio The detailed steps are nicely described here . The next picture gives a nice overview of the directory structure created. Step1 -  Create Schemas for Oracle SOA Suite and Oracle BAM (RCU) Unzip the files Run bin/rcu.bat At the Database Connection Details fill in the XE details. If you encounter the next fault you have probably not started the XE database.   Ignore all warnings Click OK Select all components I ran into the following problem: When you click Ok you see the following error: And this is about the Processes DB Init parameter that is wrong. To fix this goto the Database Home page, Sql Editor and execute the following statements: a