C# BabelFishService web service.

Hello,

I am trying use the BabelFishService translation web service. In my asp.net site, which includes C# for the coding.

The wsdl is from:

www.xmethods.com/sd/2001/BabelFishService.wsdl

In the C# code below I create a BabelFishService object and tried to translate the german word habe, which should return 'have'.

Through I found the C# code becomes locked for a time, then returns a time of exception. But does not become locked for all words I have tried to translate. I just wondered if there was an try, catch exception I could use if the webservice cannot translate the word entered?

Does anyone know if the web-service should return " " value to the string translation, if the word could not be translated by the webservice?

BabelFishService webservice = new BabelFishService();
string translation = webservice.BabelFish("de_en", "habe");

Thanks
EmailSurferAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

devsolnsCommented:
Im not sure how the web service works but yeah definaly but a try catch around it.


try {

}
catch(SoapException se)
{

}
catch(Exception e)
{

}

SoapException may contain some information.  My guess is it should return null if translation didnt take place.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EmailSurferAuthor Commented:
Thanks

Do you think the wsdl should describe the exceptions objects used in this web service? And what should be return from the BabelFish method?

http://www.xmethods.com/sd/2001/BabelFishService.wsdl

Thanks
0
EmailSurferAuthor Commented:
Could anyone advise?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

devsolnsCommented:
Well it does tell you whats expected back,

<message name="BabelFishResponse">
<part name="return" type="xsd:string" />
</message>

and its a simple string.  as far as what the service does if it cant translate that really depends on its implementation and that isnt shown in the wsdl.  i dont see any comments that tell you this.


"Do you think the wsdl should describe the exceptions objects used in this web service?"

It can but it doesnt or else you see something in the <wsdl:fault/> element.  catching the soap exception should give you whatever info you need.
0
Bob LearnedCommented:
Babelfish Reference:

Translation Web Service in C#
http://www.codeproject.com/cs/webservices/translation.asp

Bob
0
devsolnsCommented:
But that code on code project is not accessing the web service.  its using a http post method and "replicating" what youd do in a browser.
0
EmailSurferAuthor Commented:
Thanks

It seems to working now I think the web service was being timed-out.

Could I ask finally, is there anyway in C# to test if the user presses the enter in a textfield?

Thanks again
0
devsolnsCommented:
Yup,

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.textBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);
        }

        void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                //do something
            }
        }
    }
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.