Re: [R] SSOAP and Chemspider: Security token?

2012-03-09 Thread Stravs, Michael
Dear Duncan, 

thanks for the quick answer. However, I already sorted one error out - turned 
out that I was just stupid: The security token worked fine once I filled all 
the additional required information on the ChemSpider profile (which means 
the token showing up on your profile is non-functional as long as that 
information isn't complete - ChemSpider doesn't tell you that, or force you to 
fill in the information, however.)

Best,
-Michael



Message: 114
Date: Wed, 07 Mar 2012 16:57:21 -0800
From: Duncan Temple Lang dun...@wald.ucdavis.edu
To: r-help@r-project.org
Subject: Re: [R] SSOAP and Chemspider: Security token?
Message-ID: 4f5803f1.2080...@wald.ucdavis.edu
Content-Type: text/plain; charset=ISO-8859-1

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

__
R-help@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.


[R] SSOAP and Chemspider: Security token?

2012-03-07 Thread Stravs, Michael
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 - ----
# (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@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:stringAzithromycin/ns:query

  ns:token xmlns:ns=http://www.chemspider.com/; 
xsi:type=xsd:string----/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/;

  querystring/query

  tokenstring/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@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.


[R] split with lists

2011-12-22 Thread Stravs, Michael
Hi,

I have a list called spec in which a variable foundOK indicates whether or 
not the given element contains data and must be processed. I have to split the 
list and process only the good elements, and do something different later on 
with the bad elements. The code below works. However, is there a way to do the 
same thing using split(), which IMO would be more elegant?

  foundOK - which(lapply(spec, function(f) f$foundOK) == TRUE)
  foundFail - which(lapply(spec, function(f) f$foundOK) == FALSE)
  resFOK - spec[foundOK]
  resFFail - spec[foundFail]

Best,
-Michael

[[alternative HTML version deleted]]

__
R-help@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.