You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by mast <ma...@gmail.com> on 2009/05/27 13:03:51 UTC

XML validating against XSD best approach scenario

Hi,

I would like to validate an incoming xml structure that i receives from an
http request against an xsd.
My setup so far is:

http req -> http consumer su -> DefaultHttpConsumerMarshaler -> sending the
received xml further down the message exchange chain -> eip router ->
validate xml -> routes the xml to a jms provider.

My question is, what setup would be a good solution for this?
Where should i preferable validate the incoming xml? If the answer is in the
marshaller, how can I then retrieve the xsd that I would like to validate
against? Or should i use camel and from there validate the xml?

I'am using SMX 3.3.

BR
Mathias


-- 
View this message in context: http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23740272.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: XML validating against XSD best approach scenario

Posted by Gert Vanthienen <ge...@gmail.com>.
Hi Mathias,

I don't think the component actually checks the incoming message's
content type, but it's very hard to tell what the problem was without
actually seeing the exception stack trace.  The default http marshaler
should be able to handle both MEPs so that should not really make a
big difference.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/5/27 mast <ma...@gmail.com>:
>
> Hi Gert,
>
> Thank you for clearifying. The thing that confused me was when I was sending
> xml to my http consumer su and I had no marshaller present I was receiving
> an exception. When I configured a marshaller and parsed the request the
> exception went away. Looking at the
> mep(http://www.w3.org/2004/08/wsdl/in-only) that I had specified I first
> thought it had to do with the wsdl attribute and that(the http post) it had
> to be a valid soap document. But now when I am going over it in my head
> again I understand that it might have been as simple as me, forgetting to
> specify the content-type as text/xml in the post headers..
> Could this have been the case?
>
> BR
> Mathias
>
>
> Gert Vanthienen wrote:
>>
>> Mathias,
>>
>> The MEP is used to indicate the kind of interaction you want with the
>> service.
>>
>> The InOnly MEP you are using means that you'll be receiving a message,
>> but you won't be sending back a reponse message.  From the HTTP point
>> of view, this means that a POST will just be answered with an HTTP
>> status 202 (OK) but nothing else.  You can combine this with e.g. a
>> file sender or a jms provider, which just store the message somewhere.
>>
>> If you specify an InOut MEP on the HTTP consumer endpoint, this means
>> we will be sending back a response message.  If you would do the HTTP
>> POST from a browser, you would see the response XML message as a
>> result of your POST.  This also means that you would have to send the
>> message exchange to an endpoint that is capable of creating a reply,
>> e.g. a servicemix-bean or some external web service call.
>>
>> Does this clarify the meaning of the MEP attribute for you?  If your
>> flow is behaving as expected, you probably picked the right MEP.  If
>> you still have doubts on which MEP is appropriate for you, could you
>> provide us with a bit more detail on what you're trying to achieve?
>>
>> Regards,
>>
>> Gert Vanthienen
>> ------------------------
>> Open Source SOA: http://fusesource.com
>> Blog: http://gertvanthienen.blogspot.com/
>>
>>
>>
>> 2009/5/27 mast <ma...@gmail.com>:
>>>
>>> I actually wrote the first sample by using a http-marshaller class.
>>> At the time of writing it was the only familiar way for me when having to
>>> validate the incoming xml against an xsd. I will definitely try to make
>>> use
>>> of the camel validation component in the future.
>>>
>>> When sending pure non soap "xml" over http to an http-consumer-su, what
>>> mep
>>> type should I use?
>>> I'm using this as default:
>>> http://www.w3.org/2004/08/wsdl/in-only
>>>
>>> But are there other ones out there that is preferable?
>>>
>>> BR
>>> Mathias
>>>
>>>
>>> Gert Vanthienen wrote:
>>>>
>>>> Matthias,
>>>>
>>>> The benefit of creating a Marshaler for that, would be that the
>>>> validation happens very early on and you don't need to route invalid
>>>> messages through the ESB.  You can just code this up as you would
>>>> usually do validation, reading the XSD resource off the classpath or
>>>> allow people to specify a uri (either classpath or file or whatever)
>>>> to the resource on the Marshaler configuration.
>>>>
>>>> However, other than that the little excess routing, I don't see many
>>>> advantages to building this thing yourself.  Personally, I would use a
>>>> Camel route with the Camel MSV (aka
>>>> http://camel.apache.org/validation.html) in there to start with.  You
>>>> can always start coding things up yourself if you're really
>>>> experiencing any problems with the overhead, but if you're using the
>>>> SedaFlow and all exchanges are just flowing around in memory, I don't
>>>> think it will be an issue.
>>>>
>>>> Regards,
>>>>
>>>> Gert Vanthienen
>>>> ------------------------
>>>> Open Source SOA: http://fusesource.com
>>>> Blog: http://gertvanthienen.blogspot.com/
>>>>
>>>>
>>>>
>>>> 2009/5/27 mast <ma...@gmail.com>:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I would like to validate an incoming xml structure that i receives from
>>>>> an
>>>>> http request against an xsd.
>>>>> My setup so far is:
>>>>>
>>>>> http req -> http consumer su -> DefaultHttpConsumerMarshaler -> sending
>>>>> the
>>>>> received xml further down the message exchange chain -> eip router ->
>>>>> validate xml -> routes the xml to a jms provider.
>>>>>
>>>>> My question is, what setup would be a good solution for this?
>>>>> Where should i preferable validate the incoming xml? If the answer is
>>>>> in
>>>>> the
>>>>> marshaller, how can I then retrieve the xsd that I would like to
>>>>> validate
>>>>> against? Or should i use camel and from there validate the xml?
>>>>>
>>>>> I'am using SMX 3.3.
>>>>>
>>>>> BR
>>>>> Mathias
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23740272.html
>>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>> -----
>>>> ---
>>>> Gert Vanthienen
>>>> http://gertvanthienen.blogspot.com
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23746947.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>> -----
>> ---
>> Gert Vanthienen
>> http://gertvanthienen.blogspot.com
>>
>
> --
> View this message in context: http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23747831.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>

Re: XML validating against XSD best approach scenario

Posted by mast <ma...@gmail.com>.
Hi Gert,

Thank you for clearifying. The thing that confused me was when I was sending
xml to my http consumer su and I had no marshaller present I was receiving
an exception. When I configured a marshaller and parsed the request the
exception went away. Looking at the
mep(http://www.w3.org/2004/08/wsdl/in-only) that I had specified I first
thought it had to do with the wsdl attribute and that(the http post) it had
to be a valid soap document. But now when I am going over it in my head
again I understand that it might have been as simple as me, forgetting to
specify the content-type as text/xml in the post headers..
Could this have been the case?

BR
Mathias


Gert Vanthienen wrote:
> 
> Mathias,
> 
> The MEP is used to indicate the kind of interaction you want with the
> service.
> 
> The InOnly MEP you are using means that you'll be receiving a message,
> but you won't be sending back a reponse message.  From the HTTP point
> of view, this means that a POST will just be answered with an HTTP
> status 202 (OK) but nothing else.  You can combine this with e.g. a
> file sender or a jms provider, which just store the message somewhere.
> 
> If you specify an InOut MEP on the HTTP consumer endpoint, this means
> we will be sending back a response message.  If you would do the HTTP
> POST from a browser, you would see the response XML message as a
> result of your POST.  This also means that you would have to send the
> message exchange to an endpoint that is capable of creating a reply,
> e.g. a servicemix-bean or some external web service call.
> 
> Does this clarify the meaning of the MEP attribute for you?  If your
> flow is behaving as expected, you probably picked the right MEP.  If
> you still have doubts on which MEP is appropriate for you, could you
> provide us with a bit more detail on what you're trying to achieve?
> 
> Regards,
> 
> Gert Vanthienen
> ------------------------
> Open Source SOA: http://fusesource.com
> Blog: http://gertvanthienen.blogspot.com/
> 
> 
> 
> 2009/5/27 mast <ma...@gmail.com>:
>>
>> I actually wrote the first sample by using a http-marshaller class.
>> At the time of writing it was the only familiar way for me when having to
>> validate the incoming xml against an xsd. I will definitely try to make
>> use
>> of the camel validation component in the future.
>>
>> When sending pure non soap "xml" over http to an http-consumer-su, what
>> mep
>> type should I use?
>> I'm using this as default:
>> http://www.w3.org/2004/08/wsdl/in-only
>>
>> But are there other ones out there that is preferable?
>>
>> BR
>> Mathias
>>
>>
>> Gert Vanthienen wrote:
>>>
>>> Matthias,
>>>
>>> The benefit of creating a Marshaler for that, would be that the
>>> validation happens very early on and you don't need to route invalid
>>> messages through the ESB.  You can just code this up as you would
>>> usually do validation, reading the XSD resource off the classpath or
>>> allow people to specify a uri (either classpath or file or whatever)
>>> to the resource on the Marshaler configuration.
>>>
>>> However, other than that the little excess routing, I don't see many
>>> advantages to building this thing yourself.  Personally, I would use a
>>> Camel route with the Camel MSV (aka
>>> http://camel.apache.org/validation.html) in there to start with.  You
>>> can always start coding things up yourself if you're really
>>> experiencing any problems with the overhead, but if you're using the
>>> SedaFlow and all exchanges are just flowing around in memory, I don't
>>> think it will be an issue.
>>>
>>> Regards,
>>>
>>> Gert Vanthienen
>>> ------------------------
>>> Open Source SOA: http://fusesource.com
>>> Blog: http://gertvanthienen.blogspot.com/
>>>
>>>
>>>
>>> 2009/5/27 mast <ma...@gmail.com>:
>>>>
>>>> Hi,
>>>>
>>>> I would like to validate an incoming xml structure that i receives from
>>>> an
>>>> http request against an xsd.
>>>> My setup so far is:
>>>>
>>>> http req -> http consumer su -> DefaultHttpConsumerMarshaler -> sending
>>>> the
>>>> received xml further down the message exchange chain -> eip router ->
>>>> validate xml -> routes the xml to a jms provider.
>>>>
>>>> My question is, what setup would be a good solution for this?
>>>> Where should i preferable validate the incoming xml? If the answer is
>>>> in
>>>> the
>>>> marshaller, how can I then retrieve the xsd that I would like to
>>>> validate
>>>> against? Or should i use camel and from there validate the xml?
>>>>
>>>> I'am using SMX 3.3.
>>>>
>>>> BR
>>>> Mathias
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23740272.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>> -----
>>> ---
>>> Gert Vanthienen
>>> http://gertvanthienen.blogspot.com
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23746947.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -----
> ---
> Gert Vanthienen
> http://gertvanthienen.blogspot.com
> 

-- 
View this message in context: http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23747831.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: XML validating against XSD best approach scenario

Posted by Gert Vanthienen <ge...@gmail.com>.
Mathias,

The MEP is used to indicate the kind of interaction you want with the service.

The InOnly MEP you are using means that you'll be receiving a message,
but you won't be sending back a reponse message.  From the HTTP point
of view, this means that a POST will just be answered with an HTTP
status 202 (OK) but nothing else.  You can combine this with e.g. a
file sender or a jms provider, which just store the message somewhere.

If you specify an InOut MEP on the HTTP consumer endpoint, this means
we will be sending back a response message.  If you would do the HTTP
POST from a browser, you would see the response XML message as a
result of your POST.  This also means that you would have to send the
message exchange to an endpoint that is capable of creating a reply,
e.g. a servicemix-bean or some external web service call.

Does this clarify the meaning of the MEP attribute for you?  If your
flow is behaving as expected, you probably picked the right MEP.  If
you still have doubts on which MEP is appropriate for you, could you
provide us with a bit more detail on what you're trying to achieve?

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/5/27 mast <ma...@gmail.com>:
>
> I actually wrote the first sample by using a http-marshaller class.
> At the time of writing it was the only familiar way for me when having to
> validate the incoming xml against an xsd. I will definitely try to make use
> of the camel validation component in the future.
>
> When sending pure non soap "xml" over http to an http-consumer-su, what mep
> type should I use?
> I'm using this as default:
> http://www.w3.org/2004/08/wsdl/in-only
>
> But are there other ones out there that is preferable?
>
> BR
> Mathias
>
>
> Gert Vanthienen wrote:
>>
>> Matthias,
>>
>> The benefit of creating a Marshaler for that, would be that the
>> validation happens very early on and you don't need to route invalid
>> messages through the ESB.  You can just code this up as you would
>> usually do validation, reading the XSD resource off the classpath or
>> allow people to specify a uri (either classpath or file or whatever)
>> to the resource on the Marshaler configuration.
>>
>> However, other than that the little excess routing, I don't see many
>> advantages to building this thing yourself.  Personally, I would use a
>> Camel route with the Camel MSV (aka
>> http://camel.apache.org/validation.html) in there to start with.  You
>> can always start coding things up yourself if you're really
>> experiencing any problems with the overhead, but if you're using the
>> SedaFlow and all exchanges are just flowing around in memory, I don't
>> think it will be an issue.
>>
>> Regards,
>>
>> Gert Vanthienen
>> ------------------------
>> Open Source SOA: http://fusesource.com
>> Blog: http://gertvanthienen.blogspot.com/
>>
>>
>>
>> 2009/5/27 mast <ma...@gmail.com>:
>>>
>>> Hi,
>>>
>>> I would like to validate an incoming xml structure that i receives from
>>> an
>>> http request against an xsd.
>>> My setup so far is:
>>>
>>> http req -> http consumer su -> DefaultHttpConsumerMarshaler -> sending
>>> the
>>> received xml further down the message exchange chain -> eip router ->
>>> validate xml -> routes the xml to a jms provider.
>>>
>>> My question is, what setup would be a good solution for this?
>>> Where should i preferable validate the incoming xml? If the answer is in
>>> the
>>> marshaller, how can I then retrieve the xsd that I would like to validate
>>> against? Or should i use camel and from there validate the xml?
>>>
>>> I'am using SMX 3.3.
>>>
>>> BR
>>> Mathias
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23740272.html
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>> -----
>> ---
>> Gert Vanthienen
>> http://gertvanthienen.blogspot.com
>>
>
> --
> View this message in context: http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23746947.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>

Re: XML validating against XSD best approach scenario

Posted by mast <ma...@gmail.com>.
I actually wrote the first sample by using a http-marshaller class.
At the time of writing it was the only familiar way for me when having to
validate the incoming xml against an xsd. I will definitely try to make use
of the camel validation component in the future.

When sending pure non soap "xml" over http to an http-consumer-su, what mep
type should I use?
I'm using this as default:
http://www.w3.org/2004/08/wsdl/in-only

But are there other ones out there that is preferable?

BR
Mathias 


Gert Vanthienen wrote:
> 
> Matthias,
> 
> The benefit of creating a Marshaler for that, would be that the
> validation happens very early on and you don't need to route invalid
> messages through the ESB.  You can just code this up as you would
> usually do validation, reading the XSD resource off the classpath or
> allow people to specify a uri (either classpath or file or whatever)
> to the resource on the Marshaler configuration.
> 
> However, other than that the little excess routing, I don't see many
> advantages to building this thing yourself.  Personally, I would use a
> Camel route with the Camel MSV (aka
> http://camel.apache.org/validation.html) in there to start with.  You
> can always start coding things up yourself if you're really
> experiencing any problems with the overhead, but if you're using the
> SedaFlow and all exchanges are just flowing around in memory, I don't
> think it will be an issue.
> 
> Regards,
> 
> Gert Vanthienen
> ------------------------
> Open Source SOA: http://fusesource.com
> Blog: http://gertvanthienen.blogspot.com/
> 
> 
> 
> 2009/5/27 mast <ma...@gmail.com>:
>>
>> Hi,
>>
>> I would like to validate an incoming xml structure that i receives from
>> an
>> http request against an xsd.
>> My setup so far is:
>>
>> http req -> http consumer su -> DefaultHttpConsumerMarshaler -> sending
>> the
>> received xml further down the message exchange chain -> eip router ->
>> validate xml -> routes the xml to a jms provider.
>>
>> My question is, what setup would be a good solution for this?
>> Where should i preferable validate the incoming xml? If the answer is in
>> the
>> marshaller, how can I then retrieve the xsd that I would like to validate
>> against? Or should i use camel and from there validate the xml?
>>
>> I'am using SMX 3.3.
>>
>> BR
>> Mathias
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23740272.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -----
> ---
> Gert Vanthienen
> http://gertvanthienen.blogspot.com
> 

-- 
View this message in context: http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23746947.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: XML validating against XSD best approach scenario

Posted by Gert Vanthienen <ge...@gmail.com>.
Matthias,

The benefit of creating a Marshaler for that, would be that the
validation happens very early on and you don't need to route invalid
messages through the ESB.  You can just code this up as you would
usually do validation, reading the XSD resource off the classpath or
allow people to specify a uri (either classpath or file or whatever)
to the resource on the Marshaler configuration.

However, other than that the little excess routing, I don't see many
advantages to building this thing yourself.  Personally, I would use a
Camel route with the Camel MSV (aka
http://camel.apache.org/validation.html) in there to start with.  You
can always start coding things up yourself if you're really
experiencing any problems with the overhead, but if you're using the
SedaFlow and all exchanges are just flowing around in memory, I don't
think it will be an issue.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/5/27 mast <ma...@gmail.com>:
>
> Hi,
>
> I would like to validate an incoming xml structure that i receives from an
> http request against an xsd.
> My setup so far is:
>
> http req -> http consumer su -> DefaultHttpConsumerMarshaler -> sending the
> received xml further down the message exchange chain -> eip router ->
> validate xml -> routes the xml to a jms provider.
>
> My question is, what setup would be a good solution for this?
> Where should i preferable validate the incoming xml? If the answer is in the
> marshaller, how can I then retrieve the xsd that I would like to validate
> against? Or should i use camel and from there validate the xml?
>
> I'am using SMX 3.3.
>
> BR
> Mathias
>
>
> --
> View this message in context: http://www.nabble.com/XML-validating-against-XSD-best-approach-scenario-tp23740272p23740272.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>