I want to use XSLT mediator in my custom sequence to transform message for an API. I have create XSLT file name "transform.xslt" and use following syntax in my sequences.
<xslt key="transform.xslt" source="*" />
My problem is, I don't know where to put the XSLT file. Do I have to put under synapse directory or have to import to carbon repository, or is there any other configuration ?
From WSO2ESB it seems there have to be some configuration in API definition but in case of WSO2 API Manager it is automatically generated and I don't want to edit the generated file.
Thank you very much.
You can upload XSLT file as a registry resource and refer that in the XSLT mediator.
1) Save XSLT file in local registry
- Log on to the APIM Management Console.
- Click on "Browse" in the left "Registry" menu
- Expand the "system" tree node and then click on the "config"
- Then click on the "Add Resource" option
- Upload the "transform.xslt" file and give the name as "transform"
- Click on the "Add" button.
You can refer uploaded xslt file in your XSLT mediator like below.
<xslt key="conf:/transform.xslt" source="*" />
Related
Sometimes response of a service is too large that swagger cannot get and beautify response as json.
if we try with "curl" command, we get response very fast. I think this is because of "Syntax highlighting" configuration of swagger.
In this url, we can understand that one way is change this config:
springdoc.swagger-ui.syntaxHighlight.activated=false
Do you have any idea in wso2 apim 4.1.0?
Can we change API Definition for this? or we have to change core configs of wso2?
With advanced UI customization you should be able to get this done. Please refer - https://apim.docs.wso2.com/en/latest/reference/customize-product/customizations/advanced-ui-customization/
You will have to customize the Swagger UI and add the springdoc.swagger-ui.syntaxHighlight.activated property there.
In[1], it is added springdoc.swagger-ui.validatorUrl for the Swagger UI.
[1] -
https://github.com/wso2/apim-apps/blob/main/portals/devportal/src/main/webapp/source/src/app/components/Apis/Details/ApiConsole/SwaggerUI.jsx#L32
I created one file test.properties in the //wso2esb-4.9.0/repository/conf folder.
In this test.properties files I created on properties given below
testData=welcome
Now, I want to read that testData value in the proxy files in WSO2.
Here is a proxy code to get the value:
<property name="irisprop" expression="get-property('registry','conf:/iris.properties#tokenvalue')" scope="default"/>
The get-property('registry','') will fetch the values stored in the registry 1. You can refer to the documentation on 2, [3] to further clarification regarding the registry. You can use the carbon console to browse and add the registry resources.
You will not be able to read a file content directly with the property mediator. But if your use case is to use the file system to store data, you will need to use the VFS transport or the file connector. Please refer to the documentation [4], [5] to further clarify this.
1-https://docs.wso2.com/display/EI6xx/Property+Mediator#PropertyMediator-Example4:ReadingafilestoredintheRegistry
2-https://docs.wso2.com/display/ESB490/Working+with+the+Registry
[3]-https://docs.wso2.com/display/ESB490/Managing+Registry+Content
[4]-https://docs.wso2.com/display/EI6xx/VFS+Transport
[5]-https://docs.wso2.com/display/ESBCONNECTORS/File+Connector
I want to add a new child node to an XML request I'm proxying through to WSO2 DSS using an API.
The request I receive is in the following format:
<contacts>
<firstName>Bob</firstName>
<lastName>Brown</lastName>
</contacts>
I need to add an "id" node to this request that I can retrieve from a URI variable.
<contacts>
<id>1</id>
<firstName>Bob</firstName>
<lastName>Brown</firstName>
</contacts>
I've tried using the "enrich" mediator, but this seems to just wrap the ID node around the first name and last name nodes.
So I've resorted to using a script mediator to modify the request. This is what I'd like to do:
//Get XML Request from message context
var request= mc.getPayloadXML();
//Create a child node using standard E4X notation
var child = <id>1</id>;
//Append this XML to the request
request.appendChild(child);
//Replace the payload
mc.setPayloadXML(request);
Every time I try to submit this code, the WSO2 ESB API UI says that everything is cool. But when I check the underlying XML configuration, it is not cool. Where I defined "id" node is now just blank, as if it was filtered without my knowledge!
It would be great if I could add this element using a script mediator, but I'm open to other solutions.
This was actually a pretty easy fix. Just use a CDATA section to have the XML parser ignore your code.
<![CDATA[ //YOUR CODE WITH XML INLINE// ]]>
Note that for some reason the WSO2 ESB XML Editor and UI will remove the CDATA section the next time you open your sequence for editing. I generally just copy out the XML configuration to a text file and paste it back into the configuration whenever it needs to be updated.
Not a perfect solution, but it'll get you over the line.
I am trying to use Oracle Weblogic server and add WSO2 IS as SAML 2.0 Web Single Sign-on Identity Provider Partner
however to acheive this i need to generate a metadata partner file or use the one from WSO2 IS.
how can i retrieve this information from WSO2 IS or at least generate on myself?
i used the example seen here:
http://tanyamadurapperuma.blogspot.co.uk/2013/09/configure-wso2-identity-server-saml2.html
however weblogic is saying it is unable to parse the XML,
Error Unable to parse XML
Error Create operation failed - no partner created.?
I as i know content in the blog is correct... And you can use the meta data file which in there. According to the error, it may be an issue with XML file.. I guess XML file in the blog has missed the Capital letters of the XML element. Could you try out by making them capital letters. Or else following
<md:EntityDescriptor entityID="https://localhost:9443/samlsso" validUntil="2023-09-23T06:57:15.396Z">
<md:IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:KeyDescriptor use="signing">
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>MIICNTCCAZ6gAwIBAgIES343gjANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJVUzELMAkGA1UE
CAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxDTALBgNVBAoMBFdTTzIxEjAQBgNVBAMMCWxv
Y2FsaG9zdDAeFw0xMDAyMTkwNzAyMjZaFw0zNTAyMTMwNzAyMjZaMFUxCzAJBgNVBAYTAlVTMQsw
CQYDVQQIDAJDQTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzENMAsGA1UECgwEV1NPMjESMBAGA1UE
AwwJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCUp/oV1vWc8/TkQSiAvTou
sMzOM4asB2iltr2QKozni5aVFu818MpOLZIr8LMnTzWllJvvaA5RAAdpbECb+48FjbBe0hseUdN5
HpwvnH/DW8ZccGvk53I6Orq7hLCv1ZHtuOCokghz/ATrhyPq+QktMfXnRS4HrKGJTzxaCcU7OQID
AQABoxIwEDAOBgNVHQ8BAf8EBAMCBPAwDQYJKoZIhvcNAQEFBQADgYEAW5wPR7cr1LAdq+IrR44i
QlRG5ITCZXY9hI0PygLP2rHANh+PYfTmxbuOnykNGyhM6FjFLbW2uZHQTY1jMrPprjOrmyK5sjJR
O4d1DeGHT/YnIjs9JogRKv4XHECwLtIVdAbIdWHEtVZJyMSktcyysFcvuhPQK8Qc/E/Wq8uHSCo=
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</md:KeyDescriptor>
<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
Location="https://localhost:9443/samlsso"
ResponseLocation="https://localhost:9443/samlsso"/>
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Location="https://localhost:9443/samlsso"/>
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
Location="https://localhost:9443/samlsso"/>
</md:IDPSSODescriptor>
</md:EntityDescriptor>
I have saved an xml file in Configuration registry /_system/config/test.xml. My xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<ServiceDefinition>
<Source1001>Endpoint1</Source1001>
<Source1002>Endpoint2</Source1002>
</ServiceDefinition>
Now can i create a proxy to update the contents of the above xml file by use of sequence or class mediator? If i pass new endpoint= Endpoint3 and Node = Source1001 in the request of the proxy. then for the node Source1001 i should be able to see the changed endpoint as Endpoint3
Looking forward to your answers. Thanks in advance.
No built-in mediator can do this. You can write a class mediator to read the xml placed in registry, then save it after editing. You have to get the reference to registry service via osgi at the class mediator for that.
FYI. you can get the input from message context and find the values to replace.
This [1] post explains about creating class mediator to read from registry resource. Hope this will be helpful during your task.
[1] http://vvratha.blogspot.com/2013/02/accessing-registry-resources-from-class.html
You can use the following code segment within a class mediator or you can do the same with script mediator as well.
mc.getConfiguration().getRegistry().updateResource(
resourcePath, mc.getProperty("myProperty").toString().getBytes());
You can find more details on how to use either one of those mediators here