Adding a new field to a web service API call
Currently one of our applications, coded in Cache, performs web service API calls out to one of our vendors. We now need to be able to send a Client ID in the portion of the Soap envelope.
I think I have a clue of what I need to do but not 100% sure. We were thinking we could use the method %SOAP.WebClient.SetHttpHeader(field name, value) but when I have tired using this method and looked at the Soap log to see what is sent, the field is never showing. I realized I could be setting the wrong object using the method.
I have been looking at the documentation but I have not found what I need yet.
This is not using REST.
I would appreciate any suggestions.
Thanks.
Kris
Hi Kris.
What version of Caché do you have?
SetHttpHeader is correct method to add headers.
ISCSOAP began logging headers starting from 2016.1. In order to log headers you need to add "h" to the ^ISCSOAP("Log").
https://cedocs.intersystems.com/ens20161/csp/docbook/DocBook.UI.Page.cls...
Thanks for you suggestions.
I am working on Cache version 2018.1.1.312.0.
I have updated ^ISCSOAP("Log') with the "h" and i still do not see the new field showing in the log.
I think I am not using the correct object to perform the SetHttpHeader method. If I use the current object which is a class from the Vendor I don't get any errors. I was thinking the method needs to be used with the %Net.HttpRequest class but when trying that the method doesn't exist - only the SetHeader method exists. Tried that and it does not work.
Any other suggestions?
Thanks.
I made the changes you suggested and now I can see the data on the header.
Thank you!
Kris
To add a new header, you need to create a subclass of %SOAP.Header with the property you need. Once you have that then you can add it to the appropriate array e.g.
S myheader = ##class(MyNewHeader).%New()
S myheader.mykeyproperty = <myvalue>
D myservice.HeadersOut.SetAt(myheader,"MyNewHeader")
This is assuming the header is not automatically generated from the XML schema.