I have a very strange requirement in which I need to convert JSON to XML in worklight server's adapter procedure and then need to send that xml to some other systems.
I am using HTTP worklight adapter.
Is it possible to overcome this requirement in worklight adapter?
Finally i got the answer after googling a lot.
Worklight has flexibility to use java code.
I had already java code ready which serves the purpose(convert json to xml) so i just imported that class in my worklight project(copy in apps/server/ folder).
In adapter i have used that class like var xml = com.XXXX.json2xml(input);
Deploy adapter and worklight application war file and you are ready to go.
If having 3rd party library support in adapters is important to you, please open a Request for Enhancement (RFE).
Related
I want to set time zone in server. Similar we have in mule 3
https://help.mulesoft.com/s/article/How-to-properly-set-the-TimeZone-in-Mule-Mule-Runtime-and-CloudHub
But in mule 4, i don't see a way to call class file outside flow. Any suggestion?
One way i found is setting the -Duser.timezone= in VM arguments. But still looking for way at program level
To call Java classes in Mule 4 you need to add the Java Module to your project and use it to call the method. If you want to use the Spring configuration instead of calling Java from a flow, then you need to add the Spring Module. Note that you have to put the Spring bean configuration in its own pure Spring XML file. Mule 4 XML files are not Spring XML files like in Mule 3. That means the Spring XML file must not have a <mule> tag. You need to reference the Spring XML in the Mule XML (example: <spring:config name="springConfig" files="beans.xml" />).
See the examples in the Spring Module documentation if you are not familiar with Spring.
We have a web service returning an array of data from a backend system and the service is integrated using an Adapter procedure.
On one machine, when the data is returned, i notice that the JSON object name that hosted the data is called "array". As such, when i want to access the data, i use invocationResult.array . All is well.
But when my colleague gets my code and run on her machine, the JSON returned from the adapter have "text" instead as the object name for the data. With this, my code essentially is giving out error as "array" is then became unidentified.
Why is it that the object name is different on different set of machine?
UPDATE
My colleague machine runs version 6.1 Worklight Studio Plugin, while mine runs on 6.0. However another machine that runs with version 6.1 encountered no issue at all. Is this something to do with a Worklight settings?
Another info that i'm not sure will help or not, the problematic machine runs on Windows Server 2008 while others run on Windows 7 Professional
You're probably running a newer version of WL server/studio. WL adapters know how to process JSON responses. However in your case response is not JSON object, but an array. Older version of WL server treats it as plaintext, therefore you have a "text" property. Newer version of WL server knows how to handle arrays and interprets it as an array. The best approach here would be to use same lastest WL server/studio version on both machines. Alternatives might be manual conversion of array string to array object via JS APIs.
As it turns out, the problem lies in the adapter returnedContentType setting. The version on my colleague has a value 'plain' while the actual one should be 'json'
Many thanks to #Anton as it was his answer that pointed me to the correct direction.
I have created an application using IBM worklight and i am using customAuthenticator for login process
I am getting following validation error while deploying application
Security test DummyAdapter-securityTest must include user and device
realms for AuthDemo:iphone:1.0:api. [project
module_23_1_CustomLoginModule]
You need to re-read the entire Getting Started section about Authentication and Security. There is more reading material here and here.
From the error I am thinking you have added a securityTest="DummyAdapter-securityTest" attribute to your iphone element in application-descriptor.xml.
As noted by the name of the securityTest, it is not meant for the application but for the adapter. This securityTest is already defined for the adapter procedure in the adapter XML file. Remove the securityTest you've added and it will work.
The sample you are trying to run (module_23_1_CustomLoginModule) is ready-made; no need for editing. You need only to build & deploy and run it.
I've encountered a problem during development.
When the adapter is tested from within Eclipse ("Invoke Worklight procedure"), it does its job perfectly.
On the contrary, when the adapter is called from the app, it doesn't work. I receive the following error:
Error 405 HTTP method POST is not supported by this URL
I've noticed a strange thing. When the adapter is called from the test procedure the URL seems correct (/apps/services/api/...) In the other case, Worklight puts a worklight prefix (/worklight/apps/services/api/...) when it makes the call. Hence the URL cannot be reached.
Here Worklight Studio - error http 405 when connecting to mobile URL provided by Console I found a partial solution but it does not work.
Additional info
WL version is 5.0.6.
Application server is Tomcat 7.
Based on my experiments I found the problem.
Each worklight project has an application-descriptor.xml. Within it there is a tag that indicates the WL server root URL.
Since I've taken the project from another source, I've simply noticed that it was configured as
<worklightServerRootURL>http://sampleDomain/worklight</worklightServerRootURL>
where sampleDomain is only a placeholder for the real one.
Now it is configured like
<worklightServerRootURL>http://${local.IPAddress}:8080</worklightServerRootURL>
to perform internal local tests.
Hope it helps.
I am using eclipse (Juno) to develop a web service for Tomcat 7 and Axis2. I have a java bean which I want to use to create the web service. The web service wizard seems to run ok but when the server starts I get this error message:
2012-11-08 13:31:20,059 ERROR [localhost-startStop-1] configuration.EngineConfigurationFactoryServlet (EngineConfigurationFactoryServlet.java:162) getServerEngineConfig
- Unable to find config file.
Creating new servlet engine config file: /WEB-INF/server-config.wsdd
I understand this to mean that server-config.wsdd is missing. How do I create this file? Why isn't it being generated automatically by the wizard?
Update
I recreated the project and the error message does not appear. I guess that I did something wrong. Perhaps Axis1 was being used as Andreas Veithen suggests below.
That is an error message generated by Axis 1.x. If you are developing an Axis2 service, then you shouldn't attempt to deploy it on Axis 1.x.
While generating java beans or wsdl, select start service option in webservices wizard then eclipse will create the server-confid.wsdd file for you. Hope this helps.