Question
Kristina Roberts · Sep 16, 2019

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

 

 

 

 

 

 

 

00
2 0 4 179
Log in or sign up to continue

Replies

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.