requestXSLT for this soap (rest2soap-json)

48 views
Skip to first unread message

fabb...@gmail.com

unread,
Mar 22, 2019, 2:19:05 PM3/22/19
to membrane-monitor
Hi,

I am trying to make a rest2soap-json for this web service:
The request says:
----------------------------------------------------------------------------------------------------------
POST /calculator.asmx HTTP/1.1
Host: www.dneonline.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Add"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Add xmlns="http://tempuri.org/">
      <intA>int</intA>
      <intB>int</intB>
    </Add>
  </soap:Body>
</soap:Envelope>
----------------------------------------------------------------------------------------------------

Pay attention to the red highlight in <Add xmlns="http://tempuri.org">

I am using the requestXSLT get2soap.xls:
---------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
     <xsl:template match="/">
    <soap:Envelope >
     <soap:Body>
        <xsl:apply-templates select="/*/body/root/*" /> 
     </soap:Body>
    </soap:Envelope>
    </xsl:template>

    <!-- remove 'type' attribute: it's an artifact of the JSON2XML converter -->
    <xsl:template match="@type" />
    
    <!-- leave other elements alone -->
    <xsl:template match="*|@*|text()">
        <xsl:copy><xsl:apply-templates select="*|@*|text()"/></xsl:copy>
    </xsl:template>

</xsl:stylesheet>
----------------------------------------------------------------------------------------------------

in the log there is:
-------------------------------------------------------------------------------------------------------
12:20:32,493  INFO TrackingFileSystemXmlApplicationContext:583 - Refreshing Membrane Service Proxy's Spring Context
12:20:34,011  INFO Router:291 - Membrane Service Proxy 4.6.2 up and running!
12:20:37,191 ERROR LogInterceptor:136 - ==== Request ===
12:20:37,192 ERROR LogInterceptor:136 - POST /calculator.asmx HTTP/1.1

12:20:37,193 ERROR LogInterceptor:136 - Headers:
12:20:37,193 ERROR LogInterceptor:136 - Host: localhost:2000
User-Agent: curl/7.58.0
Accept: */*
Content-Type: application/json
Content-Length: 31
X-Forwarded-For: 127.0.0.1
X-Forwarded-Proto: http
X-Forwarded-Host: localhost:2000

12:20:37,193 ERROR LogInterceptor:136 - Body:
12:20:37,198 ERROR LogInterceptor:136 - {"Add":{"intA":"5","intB":"8"}}
12:20:37,198 ERROR LogInterceptor:136 - ================
12:20:37,616 ERROR LogInterceptor:136 - ==== Request ===
12:20:37,621 ERROR LogInterceptor:136 - POST /calculator.asmx HTTP/1.1

12:20:37,623 ERROR LogInterceptor:136 - Headers:
12:20:37,628 ERROR LogInterceptor:136 - Host: localhost:2000
User-Agent: curl/7.58.0
Accept: */*
Content-Length: 339
X-Forwarded-For: 127.0.0.1
X-Forwarded-Proto: http
X-Forwarded-Host: localhost:2000
SOAPAction: http://tempuri.org/Add
Content-Type: text/xml;charset=UTF-8

12:20:37,630 ERROR LogInterceptor:136 - Body:
12:20:37,642 ERROR LogInterceptor:136 - <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><Add xmlns:http="http://membrane-soa.org/schemas/http/v1/"><intA>5</intA><intB>8</intB></Add></soap:Body></soap:Envelope>
12:20:37,645 ERROR LogInterceptor:136 - ================
12:20:37,969 ERROR LogInterceptor:136 - ==== Response ===
12:20:37,970 ERROR LogInterceptor:136 - HTTP/1.1 200 OK

12:20:37,970 ERROR LogInterceptor:136 - Headers:
12:20:37,970 ERROR LogInterceptor:136 - Cache-Control: private, max-age=0
Content-Length: 325
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Fri, 22 Mar 2019 17:20:37 GMT

12:20:37,972 ERROR LogInterceptor:136 - Body:
12:20:37,974 ERROR LogInterceptor:136 - <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><AddResponse xmlns="http://tempuri.org/"><AddResult>0</AddResult></AddResponse></soap:Body></soap:Envelope>
12:20:37,974 ERROR LogInterceptor:136 - ================
12:20:38,010 ERROR LogInterceptor:136 - ==== Response ===
12:20:38,010 ERROR LogInterceptor:136 - HTTP/1.1 200 OK

12:20:38,010 ERROR LogInterceptor:136 - Headers:
12:20:38,012 ERROR LogInterceptor:136 - Cache-Control: private, max-age=0
Content-Length: 89
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Fri, 22 Mar 2019 17:20:37 GMT
Content-Type: text/xml;charset=UTF-8

12:20:38,012 ERROR LogInterceptor:136 - Body:
12:20:38,015 ERROR LogInterceptor:136 - <?xml version="1.0" encoding="UTF-8"?><AddResponse><AddResult>0</AddResult></AddResponse>
12:20:38,018 ERROR LogInterceptor:136 - ================
-------------------------------------------------------------------------------------------------------
Pay attention to the red highlight in <Add xmlns:http="http://membrane-soa.org/schemas/http/v1/"> it should be <Add xmlns="http://tempuri.org/>, why?
-------------------------------------------------------------------------------------------------------

The strip-env.xls is not working good too. This is my responseXSLT:
--------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <xsl:template match="/">
                <xsl:apply-templates select="//soap:Body/*"/>
        </xsl:template>

        <xsl:template match="@*|node()">
                <xsl:copy>
                        <xsl:apply-templates />
                </xsl:copy>
        </xsl:template>

        <!-- Get rid of the namespace prefixes in json. So

             ns1:getBank will be just getBank
        -->
        <xsl:template match="*">
                <xsl:element name="{local-name()}">
                        <xsl:apply-templates/>
                </xsl:element>
    </xsl:template>
</xsl:stylesheet>

--------------------------------------------------------------------------------------------------------------
I am using the following file with the request: calc-add.rest

curl -X POST --header "Content-Type: application/json" -d "{\"Add\":{\"intA\":\"5\",\"intB\":\"8\"}}" http://localhost:2000/calculator.asmx
------------------------------------------------------------------------------------------------------------------
and I call it: bash calc-add.rest
-------------------------------------------------------------------------------------------------------------------

The subject is make a rest call (POST with two inputs in json) --> Membrane (rest2soap-json) --> SOAP (web service)
and get the response in rest (json).

Thanks for any help.

fabian




Reply all
Reply to author
Forward
0 new messages