visual studio command prompt adding web service with authentication - web-services

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

Related

Testing Django API on a VPS with curl

I'm trying to access on my Django API using curl from my local terminal to a VSP
curl -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/
So, I tried many things like,
replace admin:password to my actual vps root#password
replace admin:password to my actual database admin#password
replace http://127.0.0.1:8000 to my vps url
replace the port 8000 by 22, or 80, 8080
And by the way, I don't know is I have to change /users/ by /root/ or anything else.
I have tried many mix and nothing works.
Here what I'm testing : http://www.django-rest-framework.org/tutorial/quickstart/#testing-our-api
If important, my vps machine is Debian 9 (Stretch)
Think you for your help
This worked for me:
curl -H 'Accept: applicatin/json; indent=4' -u [superuser username]:[superuser password] http://YOURVPSIPADDRESS/users/
The admin:password should be the superuser username and password on your Django site not the username or password for your database or VPS. Ensure a superuser has been created for your Django site on your VPS.

SonarQube 6.5 web api logout not behaving as expected?

We are trying to use sonarqube webapi and as part of prototyping I was testing the authentication apis using cURL .
The session is not getting deactivated after calling logout , and when I call a service again with a logged out cookie, it is getting authorized successfully.
Following are the steps I followed
Login
curl -v -c cookies.txt POST -d "login=admin&password=admin" http://sonar:9919/api/authentication/login
Do a user token search (which needs authorization) with the cookie
curl -b cookies.txt http://sonar:9919/api/user_tokens/search
This is successfull and returns
{"login":"admin","userTokens":[{"name":"arunvg","createdAt":"2017-10-11T15:03:18+0400"}]}
Logout
curl -v -b cookies.txt POST http://sonar:9919/api/authentication/logout
Repeat Step 2, was expecting an error message like
{"errors":[{"msg":"Authentication is required"}]}
but the call got successful and with same result in Step 2
Am I missing something here ? Any hints ?

Run a ESP local for development

When i try to run a local ESP then i get this error.
ERROR:Fetching service config failed(status code 403, reason Forbidden, url ***)
I have a new created service account this account works fine with gcloud cli.
System: OSX Sierra with Docker for MAC
this is the command that i use to start the container:
docker run -d --name="esp" --net="host" -v ~/Downloads:/esp gcr.io/endpoints-release/endpoints-runtime:1.0 -s 2017-02-07r5 -v echo.endpoints.****.cloud.goog -p 8082 -a localhost:9000 -k /esp/serviceaccount.json
UPDATE:
I have found the error i have set for the service name the verision and for the version the servicename.
Now i get no error but it not works, this is the console output from the container. From my view is all fine but it not works, i can't call the proxy with localhost:8082/***
INFO:Constructing an access token with scope https://www.googleapis.com/auth/service.management.readonly
INFO:Service account email: aplha-api#****.iam.gserviceaccount.com
INFO:Refreshing access_token
INFO:Fetching the service configuration from the service management service
nginx: [warn] Using trusted CA certificates file: /etc/nginx/trusted-ca-certificates.crt
This is the used correct command:
docker run -d --name="esp-user-api" --net="host" -v ~/Downloads:/esp gcr.io/endpoints-release/endpoints-runtime:1.0 -s echo.endpoints.***.cloud.goog -v 2017-02-07r5 -p 8082 -a localhost:9000 -k /esp/serviceaccount.json
Aron, I assume:
(1) you are following this user guide: https://cloud.google.com/endpoints/docs/running-esp-localdev
(2) And you do have a backend running on localhost:9000
Have you issued a curl request as suggested in that user guide to localhost:8082/***? does curl command get stuck or returns any error message?
If you don't have a local backend running yet, I would recommend you to follow the user guide above to run a local backend. Note this guide will instruct you to run it at port 8080, so you'll need to change your docker run command from "-a localhost:9000" to "-a localhost:8080" as well.
Also, please note this user guide is for linux env. We haven't tried this set up in a Mac env yet. We do notice some user gets this working on Windows docker with extra work, where he sets backend to "IP of docker NIC". Note "-a" is short for "--backend".
see https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/google-cloud-endpoints/4sRaSkigPiU/KY8g46NSBgAJ

Is it possible to manage WSO2 ESB connectors in commandline?

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

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