Custom SOAP header
Greetings!
Hopefully someone has an answer on this, I cannot find any example or understand from the documentation how to acheive this.
I have a SOAP header subclass
Class AddressType Extends %SOAP.Header
{
Parameter ELEMENTQUALIFIED = 1;
Parameter MAXLEN;
Parameter NAMESPACE = "urn:registry:1";
Parameter XMLNAME = "urn:LogicalAddress";
}
In my %SOAP.WebClient I use it like this:
set customHeader = ##class(AddressType).%New()
do ..HeadersOut.SetAt(customHeader,"AddressType")
Which results in
...
<SOAP-ENV:Header>
<urn:LogicalAddress xmlns="urn:registry:1" xmlns:hdr="urn:registry:1"></urn:LogicalAddress>
</SOAP-ENV:Header>
But how do I set a value within this tag? So I get the result to look like this
<urn:LogicalAddress xmlns="urn:registry:1" xmlns:hdr="urn:registry:1">Elmstreet 12</urn:LogicalAddress>
Best regards,
Magnus
Hi Magnus,
I had a look at the class reference for %SOAP.Addressing.MessageID, which is another class that extends %SOAP.Header. It defines a property to hold a MessageID.
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?P...
I notice that your class doesn't define any properties. Have you tried adding a property for the address and setting it?
-Marc
Hello Marc!
Thank you for your answer.
Yes I have tried using properties and it is working fine but it is not what I need.
Adding a property for example called Name will results in a XML like
<urn:LogicalAddress xmlns="urn:registry:1" xmlns:hdr="urn:registry:1"><Name>Elmstreet 12</Name></urn:LogicalAddress>
The SOAP.Adressing class will result in for example with you example with the MessageID,
<SOAP-ENV:Header><wsa:MessageID>The value here</wsa:MessageID> </SOAP-ENV:Header>
I need the tag to be <urn:LogicalAddress xmlns="urn:registry:1" xmlns:hdr="urn:registry:1">The value here</urn:LogicalAddress>
So that is why I need a custom SOAP header.
Best regards,
Magnus
If you add a property with an XMLPROJECTION set to CONTENT, it should be output without the wrapping tags. E.g.:
Regards,
Gertjan.
Gertjan, can you add your solution to this topic as a new "Answer"?
Thanks,
Marc
Hello Gertjan!
I have been traveling the past week but my collegue used your solution successfully, thank you very much.
If you add your solution as a new answer to this topic I will mark it as the correct solution for this question, that way it can help others in the future.
Thanks you,
Magnus