Call REST Web service using xforms:submission

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Call REST Web service using xforms:submission

Randy Smith-9
All,
I'm have a plaguing problem trying to interface Orbeon Xforms with a suite of REST web services that are usually called using C# or other object oriented languages.
In my xforms view.xml code I have the following xforms:submission which is suppose to take the instance xml and stream it to the REST service and then get back a response (not worried about the response right now) from the service:

<xforms:submission id="save-to-service" separator="&amp;" ref="instance('sourcereference-instance')" action="http://xxx/sourceservice/service.svc/uploadSourceReference" method="put">
<xforms:header>
<xforms:name>Content-Type</xforms:name>
<xforms:value?application/octet-stream</xforms:value>
</xforms:header>
<xforms:message ev:event=xforms-submit-error  ........
</xforms:submission>


I get a 400 or 404 when I call the service from XForms which tells me XForms is making the HTTP call.

The object c# code to call this service looks like this:

String results ="";
using (WebClient wc1 = new WebClient())
{
wc1.Header.Add(Content-Type", "application/octet-stream");
results = wc1.UploadFile("http://xxx/sourceservice/service_svc/uploadSourceReference", "PUT", "C:\Temp\source.xml");
string res = Encoding.UTF8.GetString(results);
return res;
}

Any thought on what am I missing or what I need to add to the XForms submission code to build the http call?
Thanks,
Randy




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Call REST Web service using xforms:submission

Hank Ratzesberger
Randy,

I presume the ?, (<xforms:value?) is an artifact...

It would be nice to view things through tcpmon or another tool
to listen 'over the wire' and see just what kind of a submission 
the service expects. Have you tried to have your service submit
to orbeon, and then serialze the results (http or xml serialzer)?

I presume Orbeon will still handle the instance as application/xml 
(i.e. regular xml), and I'm not sure how it could handle it otherwise, 
regardless of what the header requests.

I guess I am saying is I don't know what you are missing, but it is 
unusual to use octet-stream.

Regards,
Hank

On Aug 24, 2009, at 1:59 PM, Randy Smith wrote:

All,
I'm have a plaguing problem trying to interface Orbeon Xforms with a suite of REST web services that are usually called using C# or other object oriented languages.
In my xforms view.xml code I have the following xforms:submission which is suppose to take the instance xml and stream it to the REST service and then get back a response (not worried about the response right now) from the service:

<xforms:submission id="save-to-service" separator="&amp;" ref="instance('sourcereference-instance')" action="http://xxx/sourceservice/service.svc/uploadSourceReference" method="put">
<xforms:header>
<xforms:name>Content-Type</xforms:name>
<xforms:value?application/octet-stream</xforms:value>
</xforms:header>
<xforms:message ev:event=xforms-submit-error  ........
</xforms:submission>


I get a 400 or 404 when I call the service from XForms which tells me XForms is making the HTTP call.

The object c# code to call this service looks like this:

String results ="";
using (WebClient wc1 = new WebClient())
{
wc1.Header.Add(Content-Type", "application/octet-stream");
results = wc1.UploadFile("http://xxx/sourceservice/service_svc/uploadSourceReference", "PUT", "C:\Temp\source.xml");
string res = Encoding.UTF8.GetString(results);
return res;
}

Any thought on what am I missing or what I need to add to the XForms submission code to build the http call?
Thanks,
Randy



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
OW2 mailing lists service home page: http://www.ow2.org/wws

Hank Ratzesberger
NEES@UCSB
Institute for Crustal Studies,
University of California, Santa Barbara
805-893-8042







--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Call REST Web service using xforms:submission

Randy Smith-9
Hank,
The ? was a typo!
Again, we have a suite of REST web services I would like to interface with from Orbeon. I can access the web service if I know what the generated ID is for the .xml file with this submission:
<xforms:submission id="get-service"  ref="instance('sourcereference-instance')" action="http://xxx/sourceservice/service.svc/sources/0j49tje409/source.xml" method="get" replace="instance">
<xforms:message ev:event=xforms-submit-error  ........
</xforms:submission>
The problem I'm having is with:
<xforms:submission id="save-to-service" separator="&amp;" ref="instance('sourcereference-instance')" action="http://xxx/sourceservice/service.svc/uploadSourceReference" method="put">
<xforms:header>
<xforms:name>Content-Type</xforms:name>
<xforms:value>application/octet-stream</xforms:value>
</xforms:header>
<xforms:message ev:event=xforms-submit-error  ........
</xforms:submission>

Which should return an ID (which I'm not worried about now) but should take the xml instance packaged up by XForms and sent it to the service. I get a 400 error when I send it. Thought someone might have experience with OO c# calling a REST web service (see code below) and know what the Orbeon HTTP submission should be to mimic the OO code. Also, note that the octet-stream" and "Content-Type" was added after someone thought it might help. I have no idea if it should tell the XForms submission how to package up the xml and send it.
Thanks for any help!
Randy

Hank Ratzesberger wrote:
Randy,

I presume the ?, (<xforms:value?) is an artifact...

It would be nice to view things through tcpmon or another tool
to listen 'over the wire' and see just what kind of a submission 
the service expects. Have you tried to have your service submit
to orbeon, and then serialze the results (http or xml serialzer)?

I presume Orbeon will still handle the instance as application/xml 
(i.e. regular xml), and I'm not sure how it could handle it otherwise, 
regardless of what the header requests.

I guess I am saying is I don't know what you are missing, but it is 
unusual to use octet-stream.

Regards,
Hank

On Aug 24, 2009, at 1:59 PM, Randy Smith wrote:

All,
I'm have a plaguing problem trying to interface Orbeon Xforms with a suite of REST web services that are usually called using C# or other object oriented languages.
In my xforms view.xml code I have the following xforms:submission which is suppose to take the instance xml and stream it to the REST service and then get back a response (not worried about the response right now) from the service:

<xforms:submission id="save-to-service" separator="&amp;" ref="instance('sourcereference-instance')" action="http://xxx/sourceservice/service.svc/uploadSourceReference" method="put">
<xforms:header>
<xforms:name>Content-Type</xforms:name>
<xforms:value?application/octet-stream</xforms:value>
</xforms:header>
<xforms:message ev:event=xforms-submit-error  ........
</xforms:submission>


I get a 400 or 404 when I call the service from XForms which tells me XForms is making the HTTP call.

The object c# code to call this service looks like this:

String results ="";
using (WebClient wc1 = new WebClient())
{
wc1.Header.Add(Content-Type", "application/octet-stream");
results = wc1.UploadFile("http://xxx/sourceservice/service_svc/uploadSourceReference", "PUT", "C:\Temp\source.xml");
string res = Encoding.UTF8.GetString(results);
return res;
}

Any thought on what am I missing or what I need to add to the XForms submission code to build the http call?
Thanks,
Randy



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
OW2 mailing lists service home page: http://www.ow2.org/wws

Hank Ratzesberger
NEES@UCSB
Institute for Crustal Studies,
University of California, Santa Barbara
805-893-8042







--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Call REST Web service using xforms:submission

Alessandro Vernet
Administrator
Randy,

Randy Smith-9 wrote
Again, we have a suite of REST web services I would like to interface
with from Orbeon. I can access the web service if I know what the
generated ID is for the .xml file with this submission:
[...]
I am not familiar with that C# code you quoted in your first message in this thread. So like Hank suggested, could you use an HTTP analyzer, call the service with your C# code, and copy here what goes over the wire in HTTP? We can then tell you how to do that with an <xforms:submission>.

Alex