molImage for web services

User 4ba1437001

04-03-2013 02:29:28

Hi,


I came across this thread recently


https://www.chemaxon.com/forum/ftopic7654.html


which states that molImage was not working properly from Javascript (apparently not returning Base64?).  I was wondering if this problem has been fixed in 5.11.5?


I'm trying to use Mathematica to interact with JChem web services and have been able to get it to work with the standardizer and chemical terms when it returns a string (e.g. chemical formula) or number (e.g. mass, logP).  When trying to return a binary object, however, I get output that isn't being interpreted as Base64.  Before I go digging into the Mathematica documentation to figure out if the problem is on that end, I wanted to make sure that there wasn't a problem on the JChem side.


Thanks.


BoB

ChemAxon 6c76bc6409

05-03-2013 19:36:40

Hi Bob,


I think that thread is not relevant here.


I ran some tests and I think everything is fine with what JChem Web Services returns as base64 image - that is in MolConvertWS and JChemSearchWS.


A few things worth noting:



BR
Andras 

User 4ba1437001

06-03-2013 01:50:40

Andras,


  Thanks for the reply, I'll be happy to continue this discussion in a more relevant forum; I thought this was an appropriate place for integration of web services (although I am integrating it into an atypical application).


When I look at the unwrapped requests and responses, I get the following.  


For a command that works  (e.g. evaluating the mass):


Request sent to ChemicalTermsWS


 


<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'

    xmlns:xsd='http://www.w3.org/2001/XMLSchema'

    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'

    xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'>

 <soapenv:Body>

  <ns0:evaluate xmlns:ns0='http://webservice.jchem.chemaxon'>

   <ns0:target>C1=CC=C(C=C1)CC(C(=O)O)N</ns0:target>

   <ns0:expression>mass()</ns0:expression>

  </ns0:evaluate>

 </soapenv:Body>

</soapenv:Envelope>




Response


 




<?xml version='1.0' encoding='UTF-8'?>

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>

 <soapenv:Body>

  <ns:evaluateResponse xmlns:ns='http://webservice.jchem.chemaxon'>

   <ns:return>165.1891</ns:return>

  </ns:evaluateResponse>

 </soapenv:Body>

</soapenv:Envelope>


 


For a molImage request that doesn't work the Request:


 



<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'

    xmlns:xsd='http://www.w3.org/2001/XMLSchema'

    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'

    xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'>

 <soapenv:Body>

  <ns0:evaluate xmlns:ns0='http://webservice.jchem.chemaxon'>

   <ns0:target>C1=CC=C(C=C1)CC(C(=O)O)N</ns0:target>

   <ns0:expression>molImage(&apos;png&apos;)</ns0:expression>

  </ns0:evaluate>

 </soapenv:Body>

</soapenv:Envelope>


 


and the response




<?xml version='1.0' encoding='UTF-8'?>

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>

 <soapenv:Body>

  <ns:evaluateResponse xmlns:ns='http://webservice.jchem.chemaxon'>

   <ns:return>[B@138c925</ns:return>

  </ns:evaluateResponse>

 </soapenv:Body>

</soapenv:Envelope>


 


I'm very new to the whole wsdl/soap scene, so I'm not quite sure how to even to begin troubleshooting these requests/responses.  It looks to me like the response I get from the molImage request is not returning a full Base64 object even before the SOAP envelope is unwrapped.


Thanks for any feedback.  Again, I understand that this thread may be a bit too far afield.


 


BoB

ChemAxon 6c76bc6409

06-03-2013 07:58:32

I'm sorry, I misunderstood your question.


It seems molImage does indeed have problems through JChem Web Services, but I wouldn't recommend using the ChemicalTermsWS for image generation anyway. There are far better - dedicated - services available for this.


If you have a molecule and you need an image please use MolConvertWS's convert operation. I paste an example with your molecule and options below.


If you have further questions, please let me know!
Andras


Documentation: http://www.chemaxon.com/webservices/soap/MolConvertWS.html


Request:


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.jchem.chemaxon">
<soapenv:Header/>
<soapenv:Body>
<convert>
<targetStructure>C1=CC=C(C=C1)CC(C(=O)O)N</web:targetStructure>
<outputFormat>png</web:outputFormat>
</web:convert>
</soapenv:Body>
</soapenv:Envelope>

Response:


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:convertResponse xmlns:ns="http://webservice.jchem.chemaxon">
<ns:return>iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAPxUlEQVR42u2dDVDNWR/HiWwvEmlT
RLMTybJoMNrQsl7SeFmzTDu0LLurRxMrmjAM6+WRRMNsjJfGyzCx7FqepWVj9fAQNquxSUOFlpVq
...
</ns:convertResponse>
</soapenv:Body>
</soapenv:Envelope>

User 4ba1437001

06-03-2013 17:14:44

Works like a charm.  Thanks.