Hey everyone,

I have created an extension which calls some SOAP API's. I did try consuming the SOAP web service call via the built in OutSystem function but did not work as intended.

On the Visual Studio console, everything works as intended. However, when calling the extension from the application, it gives the following error:

So far I have created a web.config_XSL file in FactoryConfigurations using the following for reference: 

https://www.outsystems.com/forums/discussion/3557/customized-settings-in-web-config-files-per-espace-using-factory-configuration/


But when publishing the application on Service Studio, I get the following error:

Application Configuration
Shared Configuration '%s' is invalid and will be ignored.

This message is receiving more parameters than it uses.


Below is what is in the config file

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="https://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>

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



    <xsl:template name="ostrace">
    <switches>
      <add name="LogLevel" value="4" />
    </switches>
    <trace autoflush="true">
      <listeners>
        <!-- Default file OSTrace.log. If you have more than one eSpace with Trace Logs, please create a separate
             shared configuration for each one and change the file. -->
        <add name="MyListener" type="System.XXX.TextWriterTraceListener" initializeData="c:\Windows\Temp\OSTrace.log" />
      </listeners>
    </trace>
    </xsl:template>

    <xsl:template match="/configuration">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
            <xsl:if test="not(system.XXX)">
                <system.XXX>
                <xsl:call-template name="XXX"/>
                 <bindings>
            <basicHttpBinding>
                <binding name="XXX" allowCookies="True" />
            </basicHttpBinding>
            <customBinding>
                <binding name="XXX">
                    <textMessageEncoding messageVersion="XXX" />
                    <httpTransport allowCookies="True" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="https://URL.asmx"
                binding="basicHttpBinding" bindingConfiguration="XXX"
                contract="XXX.XXX" name="XXX" />
            <endpoint address="https://URL.asmx"
                binding="customBinding" bindingConfiguration="XXX"
                contract="XXX.XXX" name="XXX" />
        </client>
                </system.XXX>
            </xsl:if>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="/configuration/system.XXX">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
            <xsl:call-template name="ostrace"/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>


I would like to know what I am doing wrong and how to resolve this issue.


Thanks in advance, 

Suhail

Hi Suhail,

I've never seen a webservice that couldn't be consumed within the platform. Were you getting a specific error when you tried to consume it through Service Studio, or is this not possible because of other impediments?

I'm asking this because using extensions should always be a last resort and only when you cannot absolutely implement what they do within the low-code environment.

Afonso Carvalho wrote:

Hi Suhail,

I've never seen a webservice that couldn't be consumed within the platform. Were you getting a specific error when you tried to consume it through Service Studio, or is this not possible because of other impediments?

I'm asking this because using extensions should always be a last resort and only when you cannot absolutely implement what they do within the low-code environment.

Hi Afonso,

I have tried to call the SOAP API's via the built in platform. Although some of the calls worked (like log on), for others, an access denied was being thrown (although the log on call was first called).

After getting in touch with the company that provided the calls, we got the following feedback:

“The session key is included during the login response (it is returned in the header response from the server). That key needs passing back to the server otherwise it does not recognise whether the user is logged in.”

as well as:

“Can you ensure that the ASP.Net session key when calling the web methods after Login is being returned/included? If the ASP http header is blank , missing or invalid, the service will reject the call and state "Not authenticated".


Upon this, numerous fixes were attempted:

  1. I tried to set the ASP.Net cookie using https://success.outsystems.com/Documentation/11/Reference/OutSystems_APIs/HTTPRequestHandler_API#SetCookie
    But this did not overwrite the ASP cookie (created a duplicate) and the problem persisted
  2. I then proceeded to trace the calls using this as a reference: https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/SOAP/Troubleshoot_SOAP_Web_Services
    The response we got from the trace (see attached) suggested that the session ID was not being passed through the header (for the SOAP call).
  3. I then downloaded and installed the SOAPExtensibilitySamples component and proceeded to use the AddSOAPHeader_ToRequest method.
    (note installing straight from the forge threw an error for multiple members of the team. Had to download via the URL https://www.outsystems.com/forge/component-overview/5322/soap-extensibility-samples. Bug possibly?)
    The method was used directly before making the SOAP call. However, when using the application, the following error was thrown:
  4. I then proceeded to add Soap Header using EnhancedWebRefrences but the API is now deprecated on OutSystems 11
    https://success.outsystems.com/Documentation/11/Reference/OutSystems_APIs/EnhancedWebReferences_API


The same SOAP calls have been attempted on an API development environment called Postman and encountered no problems.

Would prefer to use the built in OutSystems for making SOAP calls so if someone could guide me to where I went wrong in this process and tell me a fix, I would greatly appreciate it :)

Thanks in advance,
Suhail

Regarding number 3, you write "directly before", do you recall where exactly you were calling the AddSOAPHeader_ToRequest? Were you calling it in the OnBefore request callback?

Afonso Carvalho wrote:

Regarding number 3, you write "directly before", do you recall where exactly you were calling the AddSOAPHeader_ToRequest? Were you calling it in the OnBefore request callback?

The method was called before the SOAP call was made:


That method can only be called within OnBeforeRequest. I suspect that is why you were getting that object reference error. I would recommend that you try this, and it should be enough for your authentication issues.

Afonso Carvalho wrote:

That method can only be called within OnBeforeRequest. I suspect that is why you were getting that object reference error. I would recommend that you try this, and it should be enough for your authentication issues.


Thanks for all the suggestions so far Afonso,

I am not too familiar with SOAP standards so was wondering what to put in the following fields?

Name: Name of SOAP call ("LogOn" for example)?

Namespace: the target namespace which is defined in the SOAP's WSDL file?

Value: Presuming this is where the session key goes but is there a structure that needs to be defined? If so what should it look like?


Appreciate all the help,

Suhail

I believe Name is the name of the Header key and Value would be the session key that you would receive from the initial login call. Not too sure about what the namespace would be.

You mentioned that you were in contact with the company that provides the API that you call. They should be able to provide you with an example of the authentication header that they require.