# Consuming a SOAP service that requires a complexType authentification header

Short version: Why do I get a $RecursionLimit error when calling NewSchemaInstance[SomeInstalledType] and how do I fix it? Longer version: I am trialling a vendor product that presents a web-service to dynamically construct data sets and delivers them via FTP. In production use there would be an intervening service layer between Mathematica and the vendor's web service but for trial purposes I think I should be able to just use the built-in Mathematica WebServicesLink and I'm curious why it doesn't work as expected. My trial agreement with the vendor prevents me from posting some details but I think I can be specific enough. This is my first post and I've done my best to follow protocol but please let me know if I've missed anything. Generally, each call to the web service requires a CredentialsHeader element in the SOAP header that contains a username, password, and tokenId. If the tokenId is blank or unkown, the service looks up the username and password and issues a new tokenId with the response. This tokenId can then be reused in subsequent messages to speed up response times. In Mathematica, that appears as a function argument after calling InstallService[serviceAddress.wsdl]: ?SomeFunctionWithNoActualArguments {___Data} SomeFunctionWithNoActualArguments[CredentialsHeader_CredentialsHeader] Documentation was not provided.  The CredentialsHeader element is defined in the WSDL file along with everything else and references a particular namespace: <xsd:element name="CredentialsHeader" type="typens:CredentialsHeader" /> <xsd:complexType name="CredentialsHeader"> <xsd:sequence> <xsd:element name="username" type="xsd:string"/> <xsd:element name="password" type="xsd:string"/> <xsd:element name="tokenId" type="xsd:string"/> </xsd:sequence> </xsd:complexType>  In Mathematica after calling InstallService[serviceAddress.wsdl] I can see details of the type: ?CredentialsHeader TYPE PROPERTIES Name CredentialsHeader Namespace [redacted] Global True Array False TYPE ELEMENTS Name Type MinOccurs MaxOccurs Default Fixed Symbol username String 1 1 Null Null username$735
password String 1         1         Null    Null  password$740 tokenId String 1 1 Null Null tokenId$745


However when I try to create an instance, I get an error.

NewSchemaInstance[CredentialsHeader, {"username" -> "a", "password" -> "b", "tokenId" -> ""}]
$RecursionLimit::reclim: Recursion depth of 256 exceeded. >> CredentialsHeader -> CredentialsHeader -> CredentialsHeader -> <snip> -> CredentialsHeader -> NewSchemaInstance[CredentialsHeader, {"username" -> "a", "password" -> "b","tokenId" -> ""}]  Other tested types installed by the service work as expected: ?DateRange TYPE PROPERTIES Name DateRange Namespace [redacted] Global True Array False TYPE ELEMENTS Name Type MinOccurs MaxOccurs Default Fixed Symbol start SchemaDate 1 1 Null Null start$827
end   SchemaDate 1         1         Null    Null  end\$832

NewSchemaInstance[DateRange]
DateRange["start" -> Null, "end" -> Null]


Thanks very much for any advice. Let me know if there is any more detail I can post.

-