19 Replies Latest reply on Mar 5, 2009 7:16 PM by BKBK

    SOAP and MTOM

    LogicBlast Level 1
      I'm in the final stages of consuming a web service thru SOAP using Cold Fusion 8. It's my first time using SOAP. I have everything set up to where it sends the request. I have verified the request against soapui and it matches. The request works fine with soapui. But when I call the cf page, all it brings back is the data definition wsdl (no matter what method I use).

      I have used a sniffer to make sure that the request it is sending looks good (and it does). I have contacted the company that is supplying the web service and they say that I need to send it using MTOM. They said there side isn't understanding what I'm sending since it's not using MTOM. Is Cold Fusion compatable with MTOM? If so, how do I make my SOAP request use it?

      Thanks
        • 1. SOAP and MTOM
          BKBK Adobe Community Professional & MVP
          What happens when you

          1) replace the cfoutput tag with <?xml version="1.0" encoding="UTF-8"?>
          2) remove the wsdl extension from the URL
          and
          3) change the line to
          <cfhttpparam type="xml" value="#trim(localscope.soapRequest)#">


          • 2. Re: SOAP and MTOM
            LogicBlast Level 1
            I receive an HTTP Status 500 error. If i do everything you suggested, except leave the wsdl extension in, I receive the same data definition wsdl for all of their web services.
            • 3. Re: SOAP and MTOM
              LogicBlast Level 1
              A little bit more information I found out is that the webservice is on a server running TomCat. From what I understand (my understanding COULD be wrong) is that MTOM compresses the SOAP request and then TomCat uses MTOM to decompress it.

              But if you don't send it using MTOM, then the webservice doesn't understand it so it sends back the data definition wsdl.

              I'm the first CF programmer to try and consume their webservice, so it's been very slow going/frustraiting.
              • 4. SOAP and MTOM
                BKBK Adobe Community Professional & MVP
                Did you say compress and decompress? Then add the following to your request:

                <cfhttpparam type="header" name="Accept-Encoding" value="*" />
                <cfhttpparam type="header" name="TE" value="deflate;q=0" />


                • 5. Re: SOAP and MTOM
                  LogicBlast Level 1
                  I DID say compress and decompress...added it to my code with the same results. From everything I've been reading (and there's not a lot of info out there on it), it's not looking like it can be done :(.

                  Thanks though!
                  • 6. Re: SOAP and MTOM
                    BKBK Adobe Community Professional & MVP
                    I haven't worked with MTOM but, as far as I know, it is just a SOAP enhancement that is handy when the message includes a binary attachment. Your message above -- the one within the cfsavecontent -- has no attachment. In fact, I suspect the reason you're having problems is that the message isn't a valid SOAP request for the service.

                    • 7. SOAP and MTOM
                      BKBK Adobe Community Professional & MVP
                      We could put our heads together and figure out something if we knew the relevant portion of the wsdl.

                      • 8. Re: SOAP and MTOM
                        LogicBlast Level 1
                        I used soapui to run the request and copied and pasted the request directly into that cfsavecontent, so i THINK it the request is valid. I even used the sniffer to double check what was being generated and sent by CF matched what was being sent by soapui. The main difference was the soapui has User-Agent: Jakarta Commons-HttpClient/3.1. I tried putting that in the http call: useragent="Jakarta Commons-HttpClient/3.1" but that didn't help either.

                        I will say, that this is my first time ever attempting to use SOAP requests. I use REST request to the same servers without issue, but this particular web service on their server only alows SOAP requests.

                        Take a look at the attached code, it's what the soapui is sending/recieving to/from the web service.
                        • 9. SOAP and MTOM
                          BKBK Adobe Community Professional & MVP
                          What I mean by invalid SOAP is that you should look for any reason why the message is rejected. For example, does it help to include XML processing instructions, like this?

                          <cfsavecontent variable="localscope.soapRequest"><?xml version="1.0" encoding="UTF-8" ?><soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:com=" http://com.WebServiceURL">
                          <soapenv:Header/>
                          <soapenv:Body>
                          <com:ManageProductLists catalog="spr">
                          <com:getProductList scope="application" listname="hisd"/>
                          </com:ManageProductLists>
                          </soapenv:Body>
                          </soapenv:Envelope></cfsavecontent>



                          P.S.: Leave no space between the cfsavecontent tag and the XML message. It's crucial.


                          • 10. Re: SOAP and MTOM
                            LogicBlast Level 1
                            Tried that before and again just now (with your other suggestions in place) with the same results. I made sure there was no space between the cfsavecontent and xml message.

                            The thing is, is it doesn't come back with a rejection or error message, it comes back with the entire wsdl for all of the web service.
                            • 11. Re: SOAP and MTOM
                              BKBK Adobe Community Professional & MVP
                              Could I have a go at the wsdl?

                              • 12. Re: SOAP and MTOM
                                LogicBlast Level 1
                                Sure...not sure what you want. Here is a link to the page that does the call to the web service: http://smarketingtx.com/administration/hisdsubcat.cfm

                                Are you looking for something besides that? The webservices is restricted by IP Address.

                                • 13. Re: SOAP and MTOM
                                  BKBK Adobe Community Professional & MVP
                                  Sure...not sure what you want.

                                  To have a go myself. I have.

                                  Are you looking for something besides that?

                                  Yes, things like response types and the allocation of namespace. Also, to get SOAPUI to generate a sample request for ManageProductLists.

                                  But I was none the wiser. I, too, failed to get a reasonable response from the service. It was either nothing or the wsdl, as you yourself got earlier.

                                  Ask the provider about this, sending him a copy of the SOAP request you used.


                                  • 14. Re: SOAP and MTOM
                                    LogicBlast Level 1
                                    I have already sent him a copy of the request I used and the response. That's when he said that I needed to enable mtom (which caused me to start this thread).

                                    He showed me how I could upload a list thru SOAPUI to accomplish what I'm trying to do with CF as a stop gap while I/we are trying to ge the CF side of things working. Part of that process with SOAPUI is to enable motom in the request properties. If I don't do that, the the uploading of the product list fails.

                                    That being said, when I do just a getProductList (supposed to display everything that I have uploaded/added to the product list) with soapui, I don't have mtom enabled and it works fine. That tells me that it's not an mtom issue. I have that question in to the provider. I'll post his answer when I receive it.
                                    • 15. Re: SOAP and MTOM
                                      LogicBlast Level 1
                                      Here's my IM conversation with them:

                                      [11:41] Scotty Boy: the process for sending the prod list thru soapui u showed me yesterday got me thinking...
                                      [11:41] Scotty Boy: you had me change the request properties to endable mtom...
                                      [11:42] Scotty Boy: but, when i do a getProductList with soapui, mtom is set to false and it works fine
                                      [11:42] Scotty Boy: and that is the request that i'm using in cf...so doesn't that mean mtom doesn't need to be enabled?
                                      [12:29] James: SoapUI might automatically enable mtom for responses
                                      [13:06] Scotty Boy: but i see what your response is just fine with CF...it's just your response is not what i request
                                      [13:06] Scotty Boy: it's that u don't understand my request
                                      [13:06] Scotty Boy: because u send me the whole data def wsdl
                                      [13:08] James: I think SOAPui will automatically turn it on
                                      [13:08] Scotty Boy: so then if i try and upload a new list and don't enable it...it should work?
                                      [13:08] Scotty Boy: thru soapui
                                      [13:11] James: two different things
                                      [13:12] James: 1) the xml structure in the new service is now application/xop
                                      [13:12] James: 2) attachments must be transmited via mtom
                                      • 16. Re: SOAP and MTOM
                                        BKBK Adobe Community Professional & MVP
                                        I read from this that your request should be a modified SOAP envelope, containing XOP and MTOM elements and attributes. You might also have to post the message as content-type Application/xop, as James suggests:

                                        <cfhttpparam type="header" name="content-type" value="application/xop+xml">
                                        <cfhttpparam type="header" name="SOAPAction" value="">
                                        <cfhttpparam type="header" name="content-length" value="#len(soapRequest)#">
                                        <cfhttpparam type="header" name="charset" value="utf-8">
                                        <cfhttpparam type="header" name="Accept-Encoding" value="*" />
                                        <cfhttpparam type="header" name="TE" value="deflate;q=0" />
                                        <cfhttpparam type="xml" name="message" value="#trim(soapRequest)#">

                                        Ask him for a sample of the MTOM/XOP SOAP request he talked about.



                                        • 17. Re: SOAP and MTOM
                                          LogicBlast Level 1
                                          From their wiki:

                                          What is MTOM?
                                          From Etilizewiki
                                          Jump to: navigation, search
                                          MTOM is the W3C Message Transmission Optimization Mechanism, a method of efficiently sending binary data to and from web services. It uses XOP (XML-binary Optimized Packaging) to transmit binary data and is intended to replace both MIME and DIME attachments. Binary content often has to be reencoded to be sent as text data with SOAP messages. MTOM allows more efficient sending of binary data in a SOAP request or response.


                                          Sample Raw Request:
                                          <soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:com=" http://com.etilize.spexlive">
                                          <soapenv:Header/>
                                          <soapenv:Body>
                                          <com:ManageProductLists catalog="?" siteId="0">
                                          <!--You have a CHOICE of the next 5 items at this level-->
                                          <!--0 to 25 repetitions:-->
                                          <com:task id="?">
                                          <!--You have a CHOICE of the next 6 items at this level-->
                                          <!--Optional:-->
                                          <com:insertToProductListByProductID listName="?" productId="?" ordinal="?"/>
                                          <!--Optional:-->
                                          <com:insertToProductListBySKU listName="?" type="?" number="?" ordinal="?"/>
                                          <!--Optional:-->
                                          <com:deleteFromProductListByProductID listName="?" productId="?"/>
                                          <!--Optional:-->
                                          <com:deleteFromProductListBySKU listName="?" type="?" number="?"/>
                                          <!--Optional:-->
                                          <com:deleteProductList listName="?"/>
                                          <!--Optional:-->
                                          <com:defineProductList listName="?">
                                          <!--Optional:-->
                                          <com:keywordFilter>?</com:keywordFilter>
                                          <!--Zero or more repetitions:-->
                                          <com:categoryFilter id="?" type="default"/>
                                          <!--Zero or more repetitions:-->
                                          <com:manufacturerFilter id="?"/>
                                          <!--Zero or more repetitions:-->
                                          <com:attributeFilter attributeId="?" valueId="?" operator="EQ"/>
                                          <!--Optional:-->
                                          <com:context>
                                          <!--Zero or more repetitions:-->
                                          <com:mapping key="?" value="?"/>
                                          </com:context>
                                          </com:defineProductList>
                                          </com:task>
                                          <!--Optional:-->
                                          <com:getProductList scope="application" listname="?"/>
                                          <!--Optional:-->
                                          <com:getProductListDirectory scope="application"/>
                                          <!--Optional:-->
                                          <com:uploadProductListFile listName="?">
                                          <com:file>cid:1138977549033</com:file>
                                          </com:uploadProductListFile>
                                          <!--Optional:-->
                                          <com:downloadProductListFile listName="?"/>
                                          </com:ManageProductLists>
                                          </soapenv:Body>
                                          </soapenv:Envelope>

                                          And then this is a sample of a request I sent thru soapui which automatically enables the mtom:

                                          POST /service/soap/catalog?appId=223170 HTTP/1.1
                                          Content-Type: text/xml;charset=UTF-8
                                          SOAPAction: ""
                                          User-Agent: Jakarta Commons-HttpClient/3.1
                                          Host: ws.spexlive.net
                                          Content-Length: 338

                                          <soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:com=" http://WebServiceName">
                                          <soapenv:Header/>
                                          <soapenv:Body>
                                          <com:ManageProductLists catalog="spr">
                                          <com:getProductList scope="application" listname="hisd"/>
                                          </com:ManageProductLists>
                                          </soapenv:Body>
                                          </soapenv:Envelope>
                                          HTTP/1.1 200 OK
                                          Server: Apache-Coyote/1.1
                                          Content-Type: multipart/related; type="application/xop+xml"; start="<soap.xml@xfire.codehaus.org>"; start-info="text/xml"; boundary="----=_Part_39944_20960317.1235233442949"
                                          Transfer-Encoding: chunked
                                          Date: Sat, 21 Feb 2009 16:24:02 GMT

                                          28d
                                          • 18. Re: SOAP and MTOM
                                            LogicBlast Level 1
                                            FYI...I tried the code from you last post...same results
                                            • 19. Re: SOAP and MTOM
                                              BKBK Adobe Community Professional & MVP
                                              FYI...I tried the code from you last post...same results

                                              So did I, same results. I would ask that James for a sample of the kind of request his service expects.