SmartConnector Forum
Schneider Electric support forum about SmartConnector applications for integration of other building management systems (BMS) into EcoStruxure Building Operation.
Link copied. Please paste this link to share this article on your social media post.
Good Day,
Following some successful tests using Swagger, I attempted to do further testing using the SOAPUI tool.
I saved the Swagger as an json file and imported this into SOAPUI. Reason being, the client will develop their own way of extracting the data from the SmartConnector but first they will also be using SOAPUI to do some testing.
Problem I have at the moment is I'm not sure how SOAPUI handles the Bearer token. Unfortunately there is not much detail in the EWS RESTFull Gateway manual when it comes to SOAPUI.
So the question is: after I added the username and password under the properties in SOAPUI, I get a failed to authenticate error. Assuming this is because the bearer token has not been retrieved, what other settings do I need to complete the authentication?
Link copied. Please paste this link to share this article on your social media post.
Petri,
Glad to hear you are making progress. The Swagger metadata feed allows a large ecosystem of code generators to create clients stubs and proxys. We provide a .NET sample which based on this. You can find that in the samples repository in GitHub here: https://github.com/BuildingsLabs/SmartConnectorSamples.
As to your questions on how SoapUI needs to handle the Bearer token. Well, it needs to handle it like any HTTP client would; it needs to include an Authorization header with the value 'Bearer <value of the token> which was obtained from the token endpoint.
Here's an example. I'm using a slightly older version of SoapUI (v5.2.1) so my screen shots might be different.
Note that the body contains the User Name and Password in the format:
grant_type=password&username=USERNAMEVALUE&password=PASSWORDVALUE
3. Grab the value of the Bearer Token from the response and add a Header value for another request. I'm showing "Root" since it's the simplest. The value of the header must be in the format Authorization = Bearer <TOKEN_VALUE> as shown here:
You can exercise any of the other actions similarly passing query and/or body parameters as needed but you'll always need to include the Authorization header. Remember, the Token does expire so you'll need to get an updated value when it does. You can adjust the token expiration in your Endpoint Configuration in SmartConnector but the maximum is 60 minutes. Default is 5 minutes.
Also, don't forget to double URL encode all query parameters. Body parameters don't need to be encoded like that but they do need to be in the proper format based on whatever your request format is.
Link copied. Please paste this link to share this article on your social media post.
Petri,
Glad to hear you are making progress. The Swagger metadata feed allows a large ecosystem of code generators to create clients stubs and proxys. We provide a .NET sample which based on this. You can find that in the samples repository in GitHub here: https://github.com/BuildingsLabs/SmartConnectorSamples.
As to your questions on how SoapUI needs to handle the Bearer token. Well, it needs to handle it like any HTTP client would; it needs to include an Authorization header with the value 'Bearer <value of the token> which was obtained from the token endpoint.
Here's an example. I'm using a slightly older version of SoapUI (v5.2.1) so my screen shots might be different.
Note that the body contains the User Name and Password in the format:
grant_type=password&username=USERNAMEVALUE&password=PASSWORDVALUE
3. Grab the value of the Bearer Token from the response and add a Header value for another request. I'm showing "Root" since it's the simplest. The value of the header must be in the format Authorization = Bearer <TOKEN_VALUE> as shown here:
You can exercise any of the other actions similarly passing query and/or body parameters as needed but you'll always need to include the Authorization header. Remember, the Token does expire so you'll need to get an updated value when it does. You can adjust the token expiration in your Endpoint Configuration in SmartConnector but the maximum is 60 minutes. Default is 5 minutes.
Also, don't forget to double URL encode all query parameters. Body parameters don't need to be encoded like that but they do need to be in the proper format based on whatever your request format is.
Link copied. Please paste this link to share this article on your social media post.
Hi Mark,
Just want to say thank you for this reply, it really helped me figuring out SOAPUI.
I will give the examples a crack as well at some stage when I have some time.
Thanks again.
Link copied. Please paste this link to share this article on your social media post.
Hi Mark,
I also met the SOAP UI problem, Follow the step above, I got a message: {"error": "unsupported_grant_type"}, and I attached the capture picture here. Do you know anything wrong? Thanks!
In my project, I need share the SBO data to 3rd party company via EWS. I have installed SmartConnector, added and configured SOAP EWS Rest Provider, and also tested successfully in Swagger. I attempted to do further testing using the SOAPUI tool, but didn't succeed.
BRs / Jessie
Link copied. Please paste this link to share this article on your social media post.
Hi Jie,
I don't see a request body in your request. What did you set for that?
It should look something like:
"grant_type=password&username=username&password=password"
Regards,
-Jeff
Link copied. Please paste this link to share this article on your social media post.
Hi Jessie,
Copy and paste this into the yellow portion under Media Type: grant_type=password&username=USERNAMEVALUE&password=PASSWORDVALUE
Replace the "USERNAMEVALUE" and "PASSWORDVALUE" with the Admin account details of the ES you are requesting the data from.
Link copied. Please paste this link to share this article on your social media post.
Hi Petri & Jeffrey,
Oh, Yes! Got it!
And I successfully tested it just now, Thank you very much!!
Best Regards / Jessie
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.