Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Studio conversion logic does not allow optional parameters to pass #1985

Closed
SupunTharakaSandaruwan opened this issue Jul 6, 2023 · 0 comments · Fixed by wso2/soap-to-rest#11

Comments

@SupunTharakaSandaruwan
Copy link

SupunTharakaSandaruwan commented Jul 6, 2023

Description

Freemarker template used in PayloadaFactory mediator does not allow to pass optional parameters empty,

Steps to Reproduce

  • Using the IntegartionStudio 8.2.0 create a SoapToREST API using the RemoteUserStoreManagerService wsdl
  • For the getUserCalimValues,
    • userName and profileName values are optional [2] but in the auto-generated logic, it is not considered
      auto-generated logic from IntegrationStudio 8.2.0
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header/>
    <soapenv:Body>
        <web:getUserClaimValues xmlns:web="http://service.ws.um.carbon.wso2.org">
            <web:userName>${payload.getUserClaimValues.userName}</web:userName>
            <web:profileName>${payload.getUserClaimValues.profileName}</web:profileName>
        </web:getUserClaimValues>
    </soapenv:Body>
</soapenv:Envelope>

Request Json Payload

{
  "getUserClaimValues": {
    "userName": "admin",
    "profileName": "default"
  }
}

Since the profileName is optional, if we invoke the API in MI with the following request payload, it will gives the following error at MI
Request Json Payload

{
  "getUserClaimValues": {
    "userName": "admin",
  }
}

Error

 Error parsing FreeMarker template, Syntax error or invalid reference : payload.getUserClaimValues.profileName

Steps to Resolve

Update the freemarker template to allow the optional parametes.

As an example, in order to allow the profileName attribute optional, update the the generated payload as follows

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header/>
    <soapenv:Body>
        <web:getUserClaimValues xmlns:web="http://service.ws.um.carbon.wso2.org">
            <web:userName>${payload.getUserClaimValues.userName}</web:userName>
            <#if $payload.getUserClaimValues.profileName?has_content>
            <web:profileName>${payload.getUserClaimValues.profileName}</web:profileName>
            <#else>
            <web:profileName\>
            </#if>
        </web:getUserClaimValues>
    </soapenv:Body>
</soapenv:Envelope>

[1] https://is.docs.wso2.com/en/5.9.0/develop/managing-users-and-roles-with-apis/
[2]https://is.docs.wso2.com/en/5.9.0/develop/managing-users-and-roles-with-apis/#getuserclaimvalues

Affected Component

IntegrationStudio

Version

8.2.0

Environment Details (with versions)

No response

Relevant Log Output

No response

Related Issues

No response

Suggested Labels

No response

GDLMadushanka added a commit to GDLMadushanka/soap-to-rest that referenced this issue Jul 13, 2023
Add optional value support to WSDL
Add required properties to OAS and wrap optional elements  with <#if> elements in
freemarker template
Fixes wso2/api-manager/issues/1985
GDLMadushanka added a commit to GDLMadushanka/integration-studio that referenced this issue Jul 13, 2023
Update the soap to rest dependency
Add logic to wrap optional elements with if conditions in freemarker
template
Fixes wso2/api-manager/issues/1985
GDLMadushanka added a commit to GDLMadushanka/soap-to-rest that referenced this issue Jul 14, 2023
Add optional value support to WSDL
Add required properties to OAS and wrap optional elements  with <#if> elements in
freemarker template
Fixes wso2/api-manager/issues/1985
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant