[R] SSOAP and Chemspider: Security token?

Duncan Temple Lang duncan at wald.ucdavis.edu
Thu Mar 8 01:57:21 CET 2012


Hi Michael

Thanks for the report and digging into the actual XML documents
that are sent.

It turns out that if I remove the redundant namespace definitions
and just use a single one on the <SimpleSearch> node, all is apparently fine.

I've put a pre-release version of the SSOAP package that does at

  http://www.omegahat.org/Prerelease/SSOAP_0.9-1.tar.gz

You can try that.

I'll release this version when I also fix the issue with
XMLSchema  that causes the error in genSOAPClientInterface()


BTW, the if(!is.character(token)) in the example in chemSpider.R
is an error - a mixture of !is.null() and then checking only if it
is a character.


  Best,
    Duncan

On 3/7/12 4:58 AM, Stravs, Michael wrote:
> Dear community,
> 
> has anyone managed to get SSOAP working with the ChemSpider Web APIs, using functions which need the security token?
> I use SSOAP 0.9-0 from the OmegaHat repository.
> In the example code from SSOAP there is a sample which uses a token function. Interestingly, it checks if(!is.character(token)) first (and proceeds if the token is NOT character.) I can't test that function since I have no idea how to get the token into "non-character" form :)
> 
> My code:
> 
> library(SSOAP)
> chemspider_sectoken <- "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
> # (token was here)
> cs <- processWSDL("http://www.chemspider.com/Search.asmx?WSDL")
> # intf <- genSOAPClientInterface(,cs)
> # (this fails, see below. The Mass Spec API is correctly parsed. Therefore by hand:)
> 
> csidlist <- .SOAP(server=cs at server,
>                   method="SimpleSearch",
>                   .soapArgs=list(
>                     query="Azithromycin",
>                     token=token
>                   ),
>                   action=I("http://www.chemspider.com/SimpleSearch"),
>                   xmlns=c("http://www.chemspider.com/")
>                   )
> 
> Fehler: Error occurred in the HTTP request:  Unauthorized web service usage. Please request access to this service. ---> Unauthorized web service usage. Please request access to this service.
> 
> If one looks into the request, the doc seems to be correct:
> 
> <?xml version="1.0"?>
> 
> <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> 
>   <SOAP-ENV:Body>
> 
>     <ns:SimpleSearch xmlns:ns="http://www.chemspider.com/">
> 
>       <ns:query xmlns:ns="http://www.chemspider.com/" xsi:type="xsd:string">Azithromycin</ns:query>
> 
>       <ns:token xmlns:ns="http://www.chemspider.com/" xsi:type="xsd:string">xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</ns:token>
> 
>     </ns:SimpleSearch>
> 
>   </SOAP-ENV:Body>
> 
> </SOAP-ENV:Envelope>
> 
> 
> 
> Compared to the sample request from the ChemSpider homepage:
> 
> <?xml version="1.0" encoding="utf-8"?>
> 
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> 
>   <soap:Body>
> 
>     <SimpleSearch xmlns="http://www.chemspider.com/">
> 
>       <query>string</query>
> 
>       <token>string</token>
> 
>     </SimpleSearch>
> 
>   </soap:Body>
> 
> </soap:Envelope>
> 
> 
> 
> To me, both look like perfectly fine XML and should be identical to the ChemSpider XML parser. Do I need to write the token in another format? Is something else wrong? I also tried to use .literal = T to no avail: "Error occurred in the HTTP request:  Empty query"
> 
> Best regards,
> -Michael
> 
> PS: the error message from the genSOAPClientInterface call is:
> Note: Method with signature "ClassDefinition#list" chosen for function "resolve",
> target signature "ExtendedClassDefinition#SchemaCollection".
> "SOAPType#SchemaCollection" would also be valid
> Fehler in makePrototypeFromClassDef(properties, ClassDef, immediate, where) :
>   'name' muss eine nicht-Null Zeichenkette sein
> Zusätzlich: Warnmeldung:
> undefined slot classes in definition of "ExactStructureSearchOptions": NA(class "EMatchType")
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list