Topic
  • 6 replies
  • Latest Post - ‏2013-08-16T15:13:03Z by soaDevArch
soaDevArch
soaDevArch
152 Posts

Pinned topic soap & restful ( xml/non xml)

‏2013-08-16T13:25:51Z |

Hello,

I've one requirement where

i) the incoming request could be soap --> in this case we'd need to route it to WSP service proxy

ii) we could also get xml requests ( restful calls ) based on the content type, method, uri and part of xml incoming request( like some attributes) the response will be decided. and it could be xml or non-xml (csv)

Thought of having the MPGW service and route the soap to wsp service and process if it is restful call ( and I believe we should be ok if it is a xml response). But stuck in how to deal with csv responses.

Any pointers ?.

Thanks!
Salla

 

  • swlinn
    swlinn
    1398 Posts

    Re: soap & restful ( xml/non xml)

    ‏2013-08-16T14:15:30Z  

    Hi Salla,

    If you have a service that is taking XML and non-XML requests in the same service, the only way to make that determination is to use a simple .ffd to wrap the data in an xml wrapper, and then attempt to parse the value-of that wrapper using dp:parse.  If it parses, it is XML and you can then determine if the namespace of the first element is one of the soap namespaces (1.1 or 1.2) if you need the distinction of SOAP vs XML.  For non-XML, you'll need to looks at the data to make a determination of the data type, perhaps starting and ending with { } will indicate JSON for example, or in your case, you could assume a .csv if that is the only non-XML data you would expect.

    Regards,
    Steve

  • soaDevArch
    soaDevArch
    152 Posts

    Re: soap & restful ( xml/non xml)

    ‏2013-08-16T14:24:50Z  
    • swlinn
    • ‏2013-08-16T14:15:30Z

    Hi Salla,

    If you have a service that is taking XML and non-XML requests in the same service, the only way to make that determination is to use a simple .ffd to wrap the data in an xml wrapper, and then attempt to parse the value-of that wrapper using dp:parse.  If it parses, it is XML and you can then determine if the namespace of the first element is one of the soap namespaces (1.1 or 1.2) if you need the distinction of SOAP vs XML.  For non-XML, you'll need to looks at the data to make a determination of the data type, perhaps starting and ending with { } will indicate JSON for example, or in your case, you could assume a .csv if that is the only non-XML data you would expect.

    Regards,
    Steve

    Steve... Awesomeeeeeeeeeeeeeeeeeee.
    What should be the type of response I should select on the MPGW service
    I'll be on it. Thanks so much for nice pointers!!!.

  • swlinn
    swlinn
    1398 Posts

    Re: soap & restful ( xml/non xml)

    ‏2013-08-16T14:44:15Z  

    Steve... Awesomeeeeeeeeeeeeeeeeeee.
    What should be the type of response I should select on the MPGW service
    I'll be on it. Thanks so much for nice pointers!!!.

    You're going to need to specify a response type of Non-XML if you'll potentially get  Non-XML response to your Non-XML request. If you're doing anything with the content on the response rule, then you'll need to do the same process there too as non-XML content is only made visible to your processing policy if you have a xformbin action, a httpconvert action, or you update the rule itself via the object menu and select "Enable Non-XML Processing"

    Regards,

    Steve

  • soaDevArch
    soaDevArch
    152 Posts

    Re: soap & restful ( xml/non xml)

    ‏2013-08-16T14:52:33Z  
    • swlinn
    • ‏2013-08-16T14:44:15Z

    You're going to need to specify a response type of Non-XML if you'll potentially get  Non-XML response to your Non-XML request. If you're doing anything with the content on the response rule, then you'll need to do the same process there too as non-XML content is only made visible to your processing policy if you have a xformbin action, a httpconvert action, or you update the rule itself via the object menu and select "Enable Non-XML Processing"

    Regards,

    Steve

    ahhh da da da daaaa.... that's an issue

    Steve ... based on the incoming xml request, uri, and content type and conten of the payload has
    i) xml then we'll get xml response
    ii) csv then we'll get csv response

    How to handle this ?.

    Thanks!
    Salla

  • swlinn
    swlinn
    1398 Posts

    Re: soap & restful ( xml/non xml)

    ‏2013-08-16T15:01:06Z  

    ahhh da da da daaaa.... that's an issue

    Steve ... based on the incoming xml request, uri, and content type and conten of the payload has
    i) xml then we'll get xml response
    ii) csv then we'll get csv response

    How to handle this ?.

    Thanks!
    Salla

    So your request isn't necessarily XML if the payload has non-XML .csv.  Your request type must thereby be non-XML.  If your backend is responding with non-XML, then you must have your response type as Non-XML too.  Are you doing anything with the payload or just passing it back to the client in the response rule?  If not, just make sure you don't reference the INPUT context of the response rule.  If so, then you'll need to do a binary transformation just as I suggested for the request rule earlier.  This is exactly what we did on the prior project we worked on :-)

    Regards,

    Steve

  • soaDevArch
    soaDevArch
    152 Posts

    Re: soap & restful ( xml/non xml)

    ‏2013-08-16T15:13:03Z  
    • swlinn
    • ‏2013-08-16T15:01:06Z

    So your request isn't necessarily XML if the payload has non-XML .csv.  Your request type must thereby be non-XML.  If your backend is responding with non-XML, then you must have your response type as Non-XML too.  Are you doing anything with the payload or just passing it back to the client in the response rule?  If not, just make sure you don't reference the INPUT context of the response rule.  If so, then you'll need to do a binary transformation just as I suggested for the request rule earlier.  This is exactly what we did on the prior project we worked on :-)

    Regards,

    Steve

    Yuppie Steve and I was pretty much expecting answer from you ...as we did this with you at other client/project :).

    will be working on these pieces. Thanks a ton Steve for your response!!!.

    Regards,

    Salla