Topic
  • 11 replies
  • Latest Post - ‏2013-02-20T22:49:29Z by etj
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic Setting application/soap+xml; charset=utf-8 (.NET Servers)

‏2010-09-17T16:04:08Z |
Hi,

I have 2 MPGs which are connected in series and processing the request.

Consumer and provider, both are .NET application. WSDL contract saying that request should be WS-Addressing compliant.

When I imported that WSDL into SoapUI, and send a request to DataPower, I'm seeing content type as

Content-Type: application/soap+xml;charset=UTF-8;action="http://schemas.XXXXXXXXXXXXX.com/2010/08/YYYYYYYYYYYYY/GetXXXXXXXXXXXXXXX"

And when this request passes transform action on the first gateway, this context type got changed into Content-Type: text/xml;charset=UTF-8

It removing action part from the header + it also changing it from application/soap+xml to "text/xml*. action part with the content type is required at .NET server because on the basis of it, it identify the request.

Now my question, Is this requirement can be achieved with some configuration changes on the DP or do I need to handle it in XSL?

Any other suggestion would be appreciated.

Thanks
Rohit
Updated on 2013-02-20T22:49:29Z at 2013-02-20T22:49:29Z by etj
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: Setting application/soap+xml; charset=utf-8 (.NET Servers)

    ‏2010-09-20T17:08:18Z  
    I've a soap request which is coming with content-type as "application/soap+xml" and when it passing through transform action, content-type is getting changed to "text/xml".

    Is there any way by which I can retain the content-type after transform action? Or I need to do it manually in XSL?

    Thanks
    Rohit
  • HermannSW
    HermannSW
    6737 Posts

    Re: Setting application/soap+xml; charset=utf-8 (.NET Servers)

    ‏2010-09-20T18:59:12Z  
    I've a soap request which is coming with content-type as "application/soap+xml" and when it passing through transform action, content-type is getting changed to "text/xml".

    Is there any way by which I can retain the content-type after transform action? Or I need to do it manually in XSL?

    Thanks
    Rohit
    > I've a soap request which is coming with content-type as "application/soap+xml" and when it passing through
    > transform action, content-type is getting changed to "text/xml".
    >
    > Is there any way by which I can retain the content-type after transform action? Or I need to do it manually in XSL?

    For your original question on charset.
    Opening the service via Object screen (Objects-->Service Configuration) on tab "HTTP Options" you find
    "HTTP Include charset in response-type" option. It is off by default.

    For the content type be aware that a tranform action might transform any XML type to any output type
    (XML, HTML, text, Non-XML, ...).
    So there is no relation between input and output content-type in general.
    You will have to set the content-type in XSL if the generated one is not OK for you.

    (default output method is html if root element of result document is 'html', otherwise xml )

    Hermann.
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: Setting application/soap+xml; charset=utf-8

    ‏2010-09-20T20:42:40Z  
    • HermannSW
    • ‏2010-09-20T18:59:12Z
    > I've a soap request which is coming with content-type as "application/soap+xml" and when it passing through
    > transform action, content-type is getting changed to "text/xml".
    >
    > Is there any way by which I can retain the content-type after transform action? Or I need to do it manually in XSL?

    For your original question on charset.
    Opening the service via Object screen (Objects-->Service Configuration) on tab "HTTP Options" you find
    "HTTP Include charset in response-type" option. It is off by default.

    For the content type be aware that a tranform action might transform any XML type to any output type
    (XML, HTML, text, Non-XML, ...).
    So there is no relation between input and output content-type in general.
    You will have to set the content-type in XSL if the generated one is not OK for you.

    (default output method is html if root element of result document is 'html', otherwise xml )

    Hermann.
    Thanks Herman for your explanation. I agree that I have to play with XSL to implement this requirement.

    But, I got an another interesting stuff..

    I was trying to hold the incoming "Content-Type" in the XSL file but it looks like XSL changes the content-type as soon as it executes the first line. I put a logic in the root match template to get hold the incoming Content-Type but I'm always getting default Content-Type which is text/html as I didn't mentioned any <xsl:output ...> statement is my xsl.

    so for me it looks like that you can't hold the incoming "Content-Type" in XSL because it overrides the Content-Type....

    Can you suggest someway where I can hold the incoming Content-Type?

    Thanks
    Rohit
  • alvaro_reguly@adp.com
    28 Posts

    Re: Setting application/soap+xml; charset=utf-8

    ‏2011-04-06T02:54:12Z  
    Thanks Herman for your explanation. I agree that I have to play with XSL to implement this requirement.

    But, I got an another interesting stuff..

    I was trying to hold the incoming "Content-Type" in the XSL file but it looks like XSL changes the content-type as soon as it executes the first line. I put a logic in the root match template to get hold the incoming Content-Type but I'm always getting default Content-Type which is text/html as I didn't mentioned any <xsl:output ...> statement is my xsl.

    so for me it looks like that you can't hold the incoming "Content-Type" in XSL because it overrides the Content-Type....

    Can you suggest someway where I can hold the incoming Content-Type?

    Thanks
    Rohit
    I have the same problem... I tried two things:

    setting media-type:

    <xsl:output method="xml" indent="yes" media-type="application/soap+xml"/>
    


    and explicitly overwriting Content-Type HTTP header with:

    <dp:set-http-request-header name="'Content-Type'" value="'application/soap+xml'"/>
    


    with some success, but the Results Action on my policy sets it back to text/xml.

    Any tips?
    Updated on 2014-03-25T03:32:48Z at 2014-03-25T03:32:48Z by iron-man
  • HermannSW
    HermannSW
    6737 Posts

    Re: Setting application/soap+xml; charset=utf-8

    ‏2011-04-06T10:36:51Z  
    I have the same problem... I tried two things:

    setting media-type:

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><xsl:output method="xml" indent="yes" media-type="application/soap+xml"/> </pre>

    and explicitly overwriting Content-Type HTTP header with:

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><dp:set-http-request-header name="'Content-Type'" value="'application/soap+xml'"/> </pre>

    with some success, but the Results Action on my policy sets it back to text/xml.

    Any tips?
    Hi,

    > ...
    > and explicitly overwriting Content-Type HTTP header with:
    >
    >
    
    <dp:set-http-request-header name=
    "'Content-Type'" value=
    "'application/soap+xml'"/>
    

    >
    > with some success, but the Results Action on my policy sets it back to text/xml.
    >
    > Any tips?
    >
    for me this works, I tested both in XML FW as well as MPGW.

    Please create a service with just
    • match all action
    • a transform action using contentType.xsl from INPUT to PIPE
    • a results action from PIPE to OUTPUT
    
    $ cat contentType.xsl <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
    "http://www.datapower.com/extensions" extension-element-prefixes=
    "dp" > <xsl:output omit-xml-declaration=
    "yes" /> <xsl:template match=
    "/"> <dp:set-http-request-header name=
    "'Content-Type'" value=
    "'application/soap+xml'"/> <xsl:copy-of select=
    "."/> </xsl:template> </xsl:stylesheet> $
    


    Then turn on Multistep Probe, send a request through and inspect the Headers tab of context after results action.
    You should see content type "application/soap+xml" there.
    (If you send the request with eg. curl tool you might see content type "application/x-www-form-urlencoded" in the very first context)

    So now if this works for you, too, then you need to dig into the differences of your service to this simple one.
    From which context does results action get the data?

     
    Hermann<myXsltBlog/>
  • swlinn
    swlinn
    1398 Posts

    Re: Setting application/soap+xml; charset=utf-8

    ‏2011-04-06T12:31:43Z  
    • HermannSW
    • ‏2011-04-06T10:36:51Z
    Hi,

    > ...
    > and explicitly overwriting Content-Type HTTP header with:
    >
    > <pre class="jive-pre"> <dp:set-http-request-header name= "'Content-Type'" value= "'application/soap+xml'"/> </pre>
    >
    > with some success, but the Results Action on my policy sets it back to text/xml.
    >
    > Any tips?
    >
    for me this works, I tested both in XML FW as well as MPGW.

    Please create a service with just
    • match all action
    • a transform action using contentType.xsl from INPUT to PIPE
    • a results action from PIPE to OUTPUT
    <pre class="jive-pre"> $ cat contentType.xsl <xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" xmlns:dp= "http://www.datapower.com/extensions" extension-element-prefixes= "dp" > <xsl:output omit-xml-declaration= "yes" /> <xsl:template match= "/"> <dp:set-http-request-header name= "'Content-Type'" value= "'application/soap+xml'"/> <xsl:copy-of select= "."/> </xsl:template> </xsl:stylesheet> $ </pre>

    Then turn on Multistep Probe, send a request through and inspect the Headers tab of context after results action.
    You should see content type "application/soap+xml" there.
    (If you send the request with eg. curl tool you might see content type "application/x-www-form-urlencoded" in the very first context)

    So now if this works for you, too, then you need to dig into the differences of your service to this simple one.
    From which context does results action get the data?

     
    Hermann<myXsltBlog/>
    Depending upon what you are doing in your processing rule, you may need to do a <dp:freeze-headers /> It could be that you set the header, but then a subsequent processing rule changes the content type.

    Regards,
    Steve
  • alvaro_reguly@adp.com
    28 Posts

    Re: Setting application/soap+xml; charset=utf-8

    ‏2011-04-06T16:09:05Z  
    • swlinn
    • ‏2011-04-06T12:31:43Z
    Depending upon what you are doing in your processing rule, you may need to do a <dp:freeze-headers /> It could be that you set the header, but then a subsequent processing rule changes the content type.

    Regards,
    Steve
    Thanks for all the replies.

    @HermannSW, I have attached a screen shot of the probe before my Results Action, since I have no other transforms I don't think it could be it. Seems the Content-Type change is caused by the Results Action, as odd as it seems. The previous comment had an attachment with the probe shot after the Results Action, this comment has the screenshot before the Results Action, with correct headers shown.

    @swlinn, thanks for the tip, I tried that, but to no effect as well. The headers are maintained properly up until the Results Action.
  • alvaro_reguly@adp.com
    28 Posts

    Re: Setting application/soap+xml; charset=utf-8

    ‏2011-04-06T18:22:37Z  
    Thanks for all the replies.

    @HermannSW, I have attached a screen shot of the probe before my Results Action, since I have no other transforms I don't think it could be it. Seems the Content-Type change is caused by the Results Action, as odd as it seems. The previous comment had an attachment with the probe shot after the Results Action, this comment has the screenshot before the Results Action, with correct headers shown.

    @swlinn, thanks for the tip, I tried that, but to no effect as well. The headers are maintained properly up until the Results Action.
    @HermannSW: I have tried the XSL you sent, setup a XML Firewall with loopback and posted my SOAP, got the same behavior:

    dc2stisidpct1:/opt/apache/htdocs/wsdl/401k # ./alv.sh ; echo
    * About to connect() to 172.24.18.151 port 2048
    * Connected to 172.24.18.151 (172.24.18.151) port 2048
    > POST /ADPServices/PlanService.svc HTTP/1.1
    User-Agent: curl/7.11.0 (i686-suse-linux) libcurl/7.11.0 OpenSSL/0.9.7d ipv6 zlib/1.2.1
    Host: 172.24.18.151:2048
    Pragma: no-cache
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, * / *
    Content-Type: application/soap+xml; charset=utf-8
    soapAction: "http://tempuri.org/IPlanService/PlanStatusCheck"
    Content-Length: 663
    <xml>***** I removed the body for clarity</xml>
     
    < HTTP/1.1 200 Good
    < User-Agent: curl/7.11.0 (i686-suse-linux) libcurl/7.11.0 OpenSSL/0.9.7d ipv6 zlib/1.2.1
    < Host: 172.24.18.151:2048
    < Pragma: no-cache
    < Content-Type: text/xml
    < soapAction: "http://tempuri.org/IPlanService/PlanStatusCheck"
    < Via: 1.1 ContentTypeTest
    < X-Client-IP: 172.24.18.143
    < Transfer-Encoding: chunked
    < Connection: close
    


    I am running 3.7.3.13 on XI50.

    Thanks
    Updated on 2014-03-25T03:32:40Z at 2014-03-25T03:32:40Z by iron-man
  • alvaro_reguly@adp.com
    28 Posts

    Re: Setting application/soap+xml; charset=utf-8

    ‏2011-04-07T19:47:01Z  
    @HermannSW: I have tried the XSL you sent, setup a XML Firewall with loopback and posted my SOAP, got the same behavior:

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">dc2stisidpct1:/opt/apache/htdocs/wsdl/401k # ./alv.sh ; echo * About to connect() to 172.24.18.151 port 2048 * Connected to 172.24.18.151 (172.24.18.151) port 2048 > POST /ADPServices/PlanService.svc HTTP/1.1 User-Agent: curl/7.11.0 (i686-suse-linux) libcurl/7.11.0 OpenSSL/0.9.7d ipv6 zlib/1.2.1 Host: 172.24.18.151:2048 Pragma: no-cache Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, * / * Content-Type: application/soap+xml; charset=utf-8 soapAction: "http://tempuri.org/IPlanService/PlanStatusCheck" Content-Length: 663 <xml>***** I removed the body for clarity</xml> < HTTP/1.1 200 Good < User-Agent: curl/7.11.0 (i686-suse-linux) libcurl/7.11.0 OpenSSL/0.9.7d ipv6 zlib/1.2.1 < Host: 172.24.18.151:2048 < Pragma: no-cache < Content-Type: text/xml < soapAction: "http://tempuri.org/IPlanService/PlanStatusCheck" < Via: 1.1 ContentTypeTest < X-Client-IP: 172.24.18.143 < Transfer-Encoding: chunked < Connection: close </pre>

    I am running 3.7.3.13 on XI50.

    Thanks
    Ok, I think I figured out what causes the Results Action to switch from application/soap+xml to text/xml. When I switched the Request Type from XML to SOAP, it started sending application/soap+xml.

    Seems regardless of what I send via dp:set-http-request-header, what gets actually send is based on Request Type and HTTP Include charset in response-type.

    I am now on the original problem, where .net expects lower case utf-8, and Datapower is sending UTF-8 if HTTP Include charset in response-type on the XML Firewall is enabled, even when my transform with
    <dp:set-http-request-header name="'Content-Type'" value="'application/soap+xml; utf-8'"/>
    
    sets it properly.

    If I disable HTTP Include charset in response-type on the XML Firewall, then I get only application/soap+xml. Seems Results Action overrides what was set on my transform action.

    Also, the Content-Type is correct until the Results Action on the probe, where it either drops utf-8 or converts it to UTF-8
    Updated on 2014-03-25T03:32:34Z at 2014-03-25T03:32:34Z by iron-man
  • atl30309
    atl30309
    25 Posts

    Re: Setting application/soap+xml; charset=utf-8

    ‏2013-02-11T18:01:25Z  
    Ok, I think I figured out what causes the Results Action to switch from application/soap+xml to text/xml. When I switched the Request Type from XML to SOAP, it started sending application/soap+xml.

    Seems regardless of what I send via dp:set-http-request-header, what gets actually send is based on Request Type and HTTP Include charset in response-type.

    I am now on the original problem, where .net expects lower case utf-8, and Datapower is sending UTF-8 if HTTP Include charset in response-type on the XML Firewall is enabled, even when my transform with <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><dp:set-http-request-header name="'Content-Type'" value="'application/soap+xml; utf-8'"/> </pre> sets it properly.

    If I disable HTTP Include charset in response-type on the XML Firewall, then I get only application/soap+xml. Seems Results Action overrides what was set on my transform action.

    Also, the Content-Type is correct until the Results Action on the probe, where it either drops utf-8 or converts it to UTF-8
    I am having the same problem for WSP on firmware 5.0.0.3 and 4.0.2.6. The Result action either removes (charset=utf-8;) or converts (charset=UTF-8; when "Include charset in response-type" is on)...

    Has anyone found a workaround solution? Thanks much!
  • etj
    etj
    108 Posts

    Re: Setting application/soap+xml; charset=utf-8 (.NET Servers)

    ‏2013-02-20T22:49:29Z  
    I'm having the same problem with http header when trying to send a message with mtom encoding to .net customer web service. Please let me know if you have a solution.
    Thanks,
    El