Getting started .Net WebService connection

User 3fd4be2d5f

16-08-2013 10:10:41

Hi


I want to create an app that calls the http://ourserver:8180/axis2/services/ChemicalTermsWS web service so I can pass it a connection tabel or smiles string and generate the IUPAC name for the structure. This si for integration into our ELN system so I don't need to depict the structure and the ELN will generate the connection table for me. My hope it that I don't need to install any libraries or dlls beyond what is available in the .NET Framework.


Is this possible and do you have a beginners guide for this?


Regards


Ian

ChemAxon bd13b5bd77

16-08-2013 10:26:07

Hi Ian,


 


so my understanding from your words is good when you say you would like to even go for EWeb Service rather than using local .NET API to avoid installlation of .NET libraries?


 


If so then please check this link


http://www.chemaxon.com/download/jchem-web-services/


https://restdemo.chemaxon.com/


please contact web services PM for further answers:


Gabor Guta <[email protected]>


 


Viktor

User 3fd4be2d5f

20-08-2013 08:54:24

Hi Viktor,


Thanks for that. I have e-mailed Gabor and await a reply.


cheers


Ian

User 3fd4be2d5f

20-08-2013 14:18:35

Hi Viktor,


I didn't hear from Gabor yet, but I made some progress anyway. In Visual Studio you can set the ServiceReference on the Project menu. This autogenerates the code for the client classes for the web service. I specified the namespace as ChemicalTermsWS and the following code successfully returned cyclohexane...


cheers


Ian



using WindowsFormsApplication1.ChemicalTermsWS;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            ChemicalTermsWSPortTypeClient proxy = new ChemicalTermsWSPortTypeClient("ChemicalTermsWSHttpSoap11Endpoint");
            try
            {
            
              String  name = proxy.evaluate("C1CCCCC1","name");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error fetching product details: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (proxy.State == System.ServiceModel.CommunicationState.Faulted)
                    proxy.Abort();
                else
                    proxy.Close();
            }
        }
    }
}


ChemAxon bd13b5bd77

20-08-2013 15:18:56

Hi,


the last two days were public Holiday in Hungary.


Viktor

ChemAxon 2e7d8629fa

29-08-2013 09:43:42

 Hi Ian,


 


Here is an example how can you convert a CDXML string to a MOL or a SMILES string.


 


using ChemAxon.NET.Base.Chemistry.Data;
using ChemAxon.NET.Base.Chemistry.Formats;
using ChemAxon.NET.IKVM.Chemistry;


 


            string cdxml = File.ReadAllText("benzene.cdxml"); // The string content of the CDXML file.
            MoleculeData moleculeData = new MoleculeData(cdxml, MoleculeFormat.CDXML);
            JChemMolecule molecule = new JChemMolecule(moleculeData);
            string mol = molecule.Representations.Represent(MoleculeFormat.MOL).StringData;
            string smiles = molecule.Representations.Represent(MoleculeFormat.SMILES).StringData;


 


For this, you need to install JChem .NET API what you can download from here:


http://www.chemaxon.com/download/jchem/jchem-for-net/


Inside your project you have to refer to ChemAxon.NET.Base.dll and ChemAxon.NET.IKVM.dll.


 


Best regards,


Gergely

User 3fd4be2d5f

29-08-2013 09:47:01

Thank you Gergely,


I solved my problem since posting and then deleted the post, but you were so efficient that you answered anyway - thanks :-)


I found that the CDXML string had some xml document information before the <CDXML> tag. I find if I remove that then the ChemicalTermsWS recognises the input.


 


cheers


 


Ian