SOAP request via AS:HttpRequest error

I’m trying to create SOAP request with AS:HttpRequest (string HttpRequest(string url, string method, string content, string contentType, XPathNavigator headers). I can simulate it with SoapUI without any problem. I’ve test transformation like this:

<xsl:template match="ROOT">
		<ROOT>
			<xsl:variable name="lpisContent">
  				<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v02="http://www.pds.eu/vOKO/v0200" xmlns:lpi="http://sitewell.cz/lpis/schemas/LPI_GDP01A">
				   <soapenv:Header/>
				   <soapenv:Body>
				      <v02:Request vOKOid="LPI_GDP01A">
				         <v02:RequestContent>
				            <lpi:Request>
				               <lpi:GETDATA>1</lpi:GETDATA>
				               <lpi:CTVEREC>740-1030</lpi:CTVEREC>
				               <lpi:ZKOD>1004/10</lpi:ZKOD>
				               <lpi:DATOD>2024-02-01</lpi:DATOD>
				               <lpi:DATDO>2024-02-01</lpi:DATDO>
				               <lpi:STAVID>4</lpi:STAVID>
				            </lpi:Request>
				         </v02:RequestContent>
				      </v02:Request>
				   </soapenv:Body>
				</soapenv:Envelope>
			</xsl:variable>
			<xsl:variable name="lpisHeader">
				<header name="Cache-Control" value="no-cache" />
			</xsl:variable>
			
			<xsl:variable name="lpisContentType" select="'text/xml; charset=utf-8'" />
			<xsl:variable name="lpisMethod" select="'POST'" />
			<xsl:variable name="lpisUrl" select="'https://eagritest.cz/ssl/nosso-app/EPO/WS/Online/vOKOsrv.ashx'"/>
		
			<xsl:variable name="lpisData" select="AS:HttpRequest($lpisUrl, $lpisMethod, $lpisContent, $lpisContentType, $lpisHeader)"/>
			<LPISDATA>
			
			<xsl:value-of select="AS:ToXML($lpisData)" />
			</LPISDATA>
	
		</ROOT>
	</xsl:template>

When I transform it I got error from Architect:

An error occurred during a call to extension function 'HttpRequest'. See InnerException for a complete description of the error.

and the remote server returns:

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"><SOAP:Body><SOAP:Fault><faultcode>SOAP:Client</faultcode><faultstring>Nepodařilo se načíst xml. Data at the root level is invalid. Line 1, position 1.</faultstring></SOAP:Fault></SOAP:Body></SOAP:Envelope>

I tried to capture the http request via Wireshark an it looks there is no content inside the request.

Any help is welcome :slight_smile:
Thank you.

Which Origam version are you using?

Currently 2022.1.0.2677

I’d like to first point out that using AS:HttpRequest is considered as an antipattern, because it doesn’t provide means for debugging, tracing and maintenance. It is better to use a separate workflow task HttpService.SendRequest.

That out of the way, the problem is in the input payload, which is not correctly passed to the function. See correct version below that incorporates AS:NodeToString function. The provided sample is also incorrectly spelling AS:ToXml. Tested in the latest architect.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:AS="http://schema.advantages.cz/AsapFunctions"
	xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date">

<xsl:template match="ROOT">
		<ROOT>
			<xsl:variable name="lpisContent">
  				<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v02="http://www.pds.eu/vOKO/v0200" xmlns:lpi="http://sitewell.cz/lpis/schemas/LPI_GDP01A">
				   <soapenv:Header/>
				   <soapenv:Body>
				      <v02:Request vOKOid="LPI_GDP01A">
				         <v02:RequestContent>
				            <lpi:Request>
				               <lpi:GETDATA>1</lpi:GETDATA>
				               <lpi:CTVEREC>740-1030</lpi:CTVEREC>
				               <lpi:ZKOD>1004/10</lpi:ZKOD>
				               <lpi:DATOD>2024-02-01</lpi:DATOD>
				               <lpi:DATDO>2024-02-01</lpi:DATDO>
				               <lpi:STAVID>4</lpi:STAVID>
				            </lpi:Request>
				         </v02:RequestContent>
				      </v02:Request>
				   </soapenv:Body>
				</soapenv:Envelope>
			</xsl:variable>
			<xsl:variable name="lpisHeader">
				<header name="Cache-Control" value="no-cache" />
			</xsl:variable>
			
			<xsl:variable name="lpisContentType" select="'text/xml; charset=utf-8'" />
			<xsl:variable name="lpisMethod" select="'POST'" />
			<xsl:variable name="lpisUrl" select="'https://eagritest.cz/ssl/nosso-app/EPO/WS/Online/vOKOsrv.ashx'"/>
		
			<xsl:variable name="lpisData" select="AS:HttpRequest($lpisUrl, $lpisMethod, AS:NodeToString($lpisContent), $lpisContentType, $lpisHeader)"/>
			<LPISDATA>
			
			<xsl:value-of select="AS:ToXml($lpisData)" />
			</LPISDATA>
	
		</ROOT>
	</xsl:template>
</xsl:stylesheet>

Thank you! It worked perfectly.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.