For help with installation, bugs reports or feature requests, please head over to our new forums.
	
Genuitec Community on GitHub
- This topic has 3 replies, 2 voices, and was last updated 16 years, 7 months ago by DougMH. 
- 
		AuthorPosts
- 
		
			
				
 DougMHParticipantI completed the RESTful web service tutorial … Developing JAX-RS / REST Web Services … and it worked just fine… as far as it went. Is the intent that you communicate with RESTful WS’s with http requests from Javascript? Such as… Microsoft: xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”); 
 Other browsers: xmlhttp=new XMLHttpRequest();???? With the JAX-WS tutorial, there was also a WS client that was built. Not so with this RESTful tutorial. In particular, I’m wondering how you would send an “add” request to the tutorial example. A listing of customers was… http://localhost:8080/services/customers …to list all customers and… http://localhost:8080/services/customers/<int> … to list a specific customer. It appears from the annotations… @POST 
 @Path(“add”)
 @Produces(“text/plain”)
 @Consumes(“application/xml”)…that it should be something like… http://localhost:8080/services/customers/add/< customer xml> … an example of which seems like it ought to look like… http://localhost:8080/services/customers/add/<customer><name>Bill Adama</name><address>Vancouver, Canada</address></customer> … but I was not able to get this to work. I guess in all cases you need to have a listener in your Javascript to receive the output? Thanks March 11, 2009 at 10:57 am #295817
 Brian FernandesModeratorDouglas, With the JAX-WS tutorial, there was also a WS client that was built. Not so with this RESTful tutorial. We hear you, this is something we are looking at internally. As far as adding a customer, note that the method has a @POST annotation, it’s expecting the data as HTTP Post content, not in the URL itself. 
 So you would send a request to “http://localhost:8080/services/customers/add”, and the Post data would be<customer><name>Bill Adama</name><address>Vancouver, Canada</address></customer>The above content should be used as a parameter the send method of your XMLHttpRequest object. This snippet should help: xmlhttp.setRequestHeader("Content-type", "application/xml"); xmlhttp.send("<customer><name>Bill Adama</name><address>Vancouver, Canada</address></customer>");Hope this helps. March 11, 2009 at 4:58 pm #295849
 DougMHParticipantYes it does, thank you very much. March 18, 2009 at 11:52 am #296295
 DougMHParticipantThat worked. Of course you’d want to set up a function to evaluate the response… which I didn’t do either. var objHTTP, strResult; 
 var element = document.getElementById(‘inputId’);
 var inputXml = element.value;
 var myHttp = “http://localhost:8080/restdemo/services/customers/add”;
 objHTTP = new ActiveXObject(‘Microsoft.XMLHTTP’);
 objHTTP.open(‘POST’, myHttp, false);
 objHTTP.setRequestHeader(‘Content-Type’,’application/xml’); // request monitoring function here
 objHTTP.send(inputXml);
- 
		AuthorPosts

