8/13/2020 11:53 AM | |
Posts: 17 Rating:
|
Hello all, I have to call a web service soap. I have the identifier, password, url and enveloppe. I could see there was a bloc already created to do it in the follow link " https://support.industry.siemens.com/cs/ww/en/view/109763879 " But in this bloc, I can only put the url and the body data. I can't put the password and ID. Someone knows how I have to do ? Is it easier to do it from a VBScript ? I'm using a s7-1200 (CPU1215) and a HMI TP1200. Already thank you for your help. |
Last edited by: Jen_Moderator at: 08/13/2020 12:04:43Optimized link. |
|
8/29/2020 12:41 AM | |
Joined: 7/7/2010 Last visit: 8/28/2024 Posts: 15116 Rating:
|
Change the URL string according to this pattern: http://username:password@example.com/ This gets sent in plain text over the network. If that is not a security risk (because it is inside a company firewall and is not confidential data), give is a try.
|
science guy |
|
9/10/2020 5:53 PM | |
Joined: 7/7/2010 Last visit: 8/28/2024 Posts: 15116 Rating:
|
For simplicity, let's say the URL your company's SAP team gave you is:
However, it needs the proper user / password to gain access. Let's say the user/password combo they provided is a windows domain account. For example purposes:
The URL the PLC is required to use is:
The data portion would be the required header(s), POST verb, and SOAP SAP XML. You can try this out from your computer by using the above URL as an example, and the payload (data) part you craft (or ask your SAP team to provide all the data sent for the SOAP POST request). POSTMAN is a tool that can help you troubleshoot the url and data values required to successfully request data. I would get it working in postman and then it will be very easy to convert that to PLC text. Just be sure you use the correct line terminator for web traffic. CRLF ('$R$N' is the TIA Portal string for CRLF - taken from the F1-Help searching for carriage return line feed) This link may also help if the the SAP SOAP web service allows (or requires) passing the credentials as part of the POST data: https://www.soapui.org/docs/soap-and-wsdl/working-with-messages/ Try it, and I think you might return here with a "solved" post.
|
Last edited by: 0_Einstein at: 09/10/2020 17:55:08Last edited by: 0_Einstein at: 09/10/2020 18:11:44science guy |
|
This contribution was helpful to
1 thankful Users |
9/11/2020 2:28 PM | |
Posts: 17 Rating:
|
Hello Einstein ! It works on POSTMAN ! I have the URL and the data values.
I converted to http code and replaced the new line by '$R$N'
but I still have 2 problems
Should I really use this bloc ? or should I use the bloc TSEND_C and TRCV_C ? Thanky you ! |
9/11/2020 3:08 PM | |
Joined: 7/7/2010 Last visit: 8/28/2024 Posts: 15116 Rating:
|
I am glad you found a way to verify the url and data (using postman). It is unfortunate the requested data is not available in json format since that's much less data to send. You have a couple options. Like you suggested, using tcp sending / receiving instructions in which you validate everything yourself (see https://support.industry.siemens.com/tf/ww/en/posts/http-post/176659 ), OR, you could modify the L_HTTP library for POST so it accepts a data blob (array of char) instead of a string. I would probably opt for making a change to working code since all the rest of the work Siemens did is very helpful. Another option is to submit a support request asking how to send more than 254 characters in the message body for the http post instruction in that library. It's a valid request which should result in a library change - at some point in the future. But if your project has a real deadline, do not wait for it... I was looking around for another library that has a similar http post request that uses array of char for the message data. Perhaps you could do some of that as well. I only looked in one place, and it only had http get.
|
science guy |
|
9/11/2020 4:00 PM | |
Joined: 7/7/2010 Last visit: 8/28/2024 Posts: 15116 Rating:
|
Ok, I opened the LHTTP_Post block and it only references the post's message data parameter in 2 places. After starting at it, the block should work for an s7-1200. You just have to recompile / rebuild all for it to work. While I was staring inside the state machine region, and the init region inside that, I saw what looked like a simple opportunity to save a lot of work for your specific situation where you already have a working post data "blob" (used successfully in postman). So, I added 2 input parameters, "blob", and "blob_len". If blob_len = 0, it uses the existing "data" string as input source for the post message data. However, if blob_len > 0 (and less than 668 - from other datatype type restrictions), "data" is ignored, and "blob" is used as the post data. Attached is that scl file you can import using "external source". It has not been tested, but _should_ work if all my assumptions were valid. AttachmentLHTTP_Post_v1.0.1a.zip (703 Downloads) |
science guy |
|
This contribution was helpful to
2 thankful Users |
Follow us on