0

I'm new to java script and html. I have a web service running (I'm sure it is working).

I have this part in my html-

<html>
  <body bgcolor="#E6E6FA">
  <head>
   <title>Blog Site</title>
    <script language="JavaScript">
     function InitializeService(){
     alert("init");
      try{
      service.useService(http://localhost:7777/BlogServer.asmx?wsdl,"GetBlogServer");
      } catch(e){alert(e.message);}
    alert("done");
     }

     var mailAddress, title, body;
     function CreateNewEntry(){
      mailAddress = document.DemoForm.StringMAilAddress.value;
      title = document.DemoForm.StringTitle.value;
      body = document.DemoForm.StringBody.value;  alert("send");
      service.GetBlogServer.callService("enterNewInput", mailAddress, title, body);
     }
     function ShowServerAnswerToNewEntry(){
    alert(event.result.value);
      }
     </script>
    </head>
     <body onload="InitializeService()" id="service" 
    style="behavior:url(webservice.htc)" onresult="ShowServerAnswerToNewEntry()">
      <form name="NewInput">
       Mail address :<br> <input type="text" name="StringMAilAddress"/> <br>
       Title :<br> <input type="text" name="StringTitle"/><br>
       Body: <p><textarea name="StringBody" cols="50" rows="10"></textarea></p>
       <button onclick="CreateNewEntry()">Insert new post</button>
      </form>
      <p id="result"></p>

     </body>
 <

/html>

I can see that the service.useService(http://localhost:7777/BlogServer.asmx?wsdl,"GetBlogServer"); part is not working, but I don't know why. any help?

boaz
  • 920
  • 1
  • 13
  • 32
  • This code appears very outdated. It seems to access a SOAP web service using Microsoft [webservice.htc](http://www.microsoft.com/en-nz/download/details.aspx?id=18378) and [IE behaviors](https://msdn.microsoft.com/en-us/library/ms531079%28v=vs.85%29.aspx) "obsolete as of Internet Explorer 10". To make it work you'll probably need to be using IE and set it to emulate version < 10 in the dev console. – Yogi May 31 '15 at 20:03
  • @Robert thank you, I'll try that. Is there a better way to use java webservice with html? I need to create a simple site... – boaz May 31 '15 at 20:14
  • It's actually a .NET (C#) web service that you are calling. You can tell because the service name is ".asmx" And if you enter the web service URL in your browser (remove ?wsdl) it should give you a help page with information. Yet, explaining how to do a SOAP call with Javascript can't be answered in a comment. If this is just a leaning project then your time might be better spent leaning [REST](http://stackoverflow.com/questions/2131965/main-differences-between-soap-and-restful-web-services-in-java), which is a newer alternative. – Yogi May 31 '15 at 23:26

0 Answers0