Is it possible to manage WSO2 ESB connectors in commandline? - wso2

I have a custom made WSO2 ESB connector. I want to automate the installation of this connector. The documentation explains how to enable the connector using the management console. Is there also a commandline interface to manage/enable connectors?
Thanks!

You can enable / disable a connector with an admin service (webService) called MediationLibraryAdminService
To see it's WSDL : https://localhost:9443/services/MediationLibraryAdminService?wsdl
(you must edit repository/conf/carbon.xml and change HideAdminServiceWSDLs to false : <HideAdminServiceWSDLs>false</HideAdminServiceWSDLs> )
Sample request to enable a connector "MyConnector" in a package "my.package" :
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.synapse/xsd">
<soap:Header/>
<soap:Body>
<xsd:updateStatus>
<xsd:libQName>{my.package}MyConnector</xsd:libQName>
<xsd:libName>MyConnector</xsd:libName>
<xsd:packageName>my.package</xsd:packageName>
<xsd:status>enabled</xsd:status>
</xsd:updateStatus>
</soap:Body>
You can call this service in command line with curl :
save above request in a file named request.xml and type this command line
with curl 7.40 :
curl --basic -u admin:admin -H "Content-Type: application/soap+xml" -k -d #request.xml https://192.168.0.33:9443/services/MediationLibraryAdminService.MediationLibraryAdminServiceHttpsSoap12Endpoint

Related

Calling Webservice from NIFI with proxy

I need to configure a NIFI flow that invokes a webservice. The curl command works fine from the cmd line of my nifi host
curl -U <user>:<password> -x <ip>:8080 -H 'SOAPACTION:"http://method"'-X POST -H 'Content-type: text/xml' -d #req.xml https://url -o result2.xml
Im trying to configure NIFI InvokeHTTP processor to make the call from within a nifi flow with following settings.
HTTP Method:POST
Remote URL: https://url
Proxy Host: <ip>
Proxy Port: 8080
Proxy Username: <user>
Proxy Password: <password>
SOAPAction: method (Dynamic Properties)
But it keeps running in the Failure queue.
how do i configure my InvokeHTTP according to the curl command which works ok?
We updated the version of the InvokeHTTP component from 1.3.0 to the newest

WSO2 API Manager 2.0.0 : white screen on the application view screen when running as a systemd service

Consecutively to WSO2 API Manager 2.0.0 : white screens after installing https certificate, I've just installed a fresh new WSO2 API Manager (single node) from the 2.0.0 zip distribution using MySQL Database to try to avoid problems related to H2 database.
After the install is complete, it starts with no warning and no error (after a few tries to get all things right in master-datasources.xml).
In publisher, I can log in as admin, create a new API, import swagger json contract, finalize API with no problem.
In store, I can log in as admin, view the API I've just created, create a new application via the right-side drop down menu, subscribe to it.
BUT when I try to open an application in order to generate keys and token, I just get a white empty screen. Nothing can help me in the logs :
[29/Nov/2016:16:17:33 +0100] "GET /store/site/pages/application.jag?name=MyNewApp&tenant=carbon.super HTTP/1.1" 200 3 "https://10.22.106.101:9443/store/site/pages/applications.jag?tenant=carbon.super" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"
EDIT :
A few minutes after I get the page crash (maybe not related ?) I have this printing repeatedly in wso2carbon.log :
WARN {sun.rmi.transport.tcp.TCPTransport$AcceptLoop} - RMI TCP Accept-11111: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,localport=11111] throws {sun.rmi.transport.tcp.TCPTransport$AcceptLoop}
java.lang.OutOfMemoryError: unable to create new native thread
Again, this is a basic installation (unzip) plugged into MySQL database with no customization/configuration.
EDIT 2 : So I think I have found the cause, but not the solution. This problem does not occur when I launch via direct command line, it occurs only when I launch through systemd service :
sudo sytemctl start wso2am.service
/etc/systemd/system/wso2am.service :
[Unit]
Description=WSO2 API Manager
[Service]
User=linc
ExecStart=/bin/bash -c ". /etc/profile.d/setenv.sh; /home/linc/wso2am-2.0.0/bin/wso2server.sh start"
Type=forking
[Install]
WantedBy=multi-user.target
So is WSO2 not compatible with systemd launching ? or am I missing some parameter ?
I have followed this blog post to run APIM as a Linux service. Please have a look. It should work without a problem. (Make sure to add #!bin/sh at the top of myService.sh)
Finally I have WSO2 API manager running as a Systemd service.
This is my 'wso2apim.service' file
[Unit]
Description=WSO2 API Manager
[Service]
Environment= JAVA_HOME=/usr/lib/jvm/java-8-oracle
WorkingDirectory=/opt/wso2/wso2am-2.0.0
User=wso2
ExecStart=/bin/bash /opt/wso2/wso2am-2.0.0/bin/wso2server.sh
ExecStop= /bin/bash -c '/opt/wso2/wso2am-2.0.0/bin/wso2server.sh stop'
ExecReload=/bin/bash -c '/opt/wso2/wso2am-2.0.0/bin/wso2server.sh restart'
[Install]
WantedBy=multi-user.target
It's simple, but tricky
The service type is simple (not fork or either). (Default value)
The ExecStart has not to include the 'start' option. With the
start option, it tries a nohup, that is not working
But, the stop has to include the stop options
Hope it helps

WSO2 DAS 3.0.1 proxy server configuration

How can I configure the WSO2 DAS 3.0.1 to get through Proxy server in organization because it cannot download Google library when starting?
Cheers,
Sean
You can pass below properties as JVM options when starting the server to configure the proxy settings.
./wso2server.sh -Dhttp.proxyHost=10.100.1.100 -Dhttp.proxyPort=8088 -Dhttp.nonProxyHosts="localhost|127.0.0.1"
Alternatively you can append those parameters to the existing JVM options in the wso2server.sh.
-Dhttp.proxyHost=10.100.1.100 \
-Dhttp.proxyPort=8088 \
-Dhttp.nonProxyHosts="localhost|127.0.0.1" \

visual studio command prompt adding web service with authentication

I need to test a web service in visual studio command prompt.
This web service needs authentication in order to be added or created.
How do I set those authentication (ie: The username and password needed to pass the web service)?
Try wget:
wget --http-user=<user> --http-password=<pass> https://<url>
For the webcall arguments see here e.g.
wget --post-file "hello.xml" --header "content-type: text/xml;charset=utf-8" --header "SOAPAction: http://tepmuri.org/myservice/IService/Hello" http://localhost/Service.svc

How to test web service using command line curl

I am building a web service for a web application, and I would like a simple tool to test this as I am developing. I have tried some firefox plug-ins (Poster, 'REST Client'), and even though these work fine I have been unable to upload files with them.
Also, I would rather have a command-line tool that I can use to easily write a set of integration tests for this web service and that I can send to consumers of this web service as an example.
I know that curl can work for this but would like a few examples, especially around authentication (using HTTP Basic) and file uploads.
Answering my own question.
curl -X GET --basic --user username:password \
https://www.example.com/mobile/resource
curl -X DELETE --basic --user username:password \
https://www.example.com/mobile/resource
curl -X PUT --basic --user username:password -d 'param1_name=param1_value' \
-d 'param2_name=param2_value' https://www.example.com/mobile/resource
POSTing a file and additional parameter
curl -X POST -F 'param_name=#/filepath/filename' \
-F 'extra_param_name=extra_param_value' --basic --user username:password \
https://www.example.com/mobile/resource
In addition to existing answers it is often desired to format the REST output (typically JSON and XML lacks indentation). Try this:
$ curl https://api.twitter.com/1/help/configuration.xml | xmllint --format -
$ curl https://api.twitter.com/1/help/configuration.json | python -mjson.tool
Tested on Ubuntu 11.0.4/11.10.
Another issue is the desired content type. Twitter uses .xml/.json extension, but more idiomatic REST would require Accept header:
$ curl -H "Accept: application/json"
From the documentation on http://curl.haxx.se/docs/httpscripting.html :
HTTP Authentication
curl --user name:password http://www.example.com
Put a file to a HTTP server with curl:
curl --upload-file uploadfile http://www.example.com/receive.cgi
Send post data with curl:
curl --data "birthyear=1905&press=%20OK%20" http://www.example.com/when.cgi