Author |
Message
|
mehdiK |
Posted: Tue Mar 12, 2013 7:41 am Post subject: Can't get message input : Error 500 |
|
|
Acolyte
Joined: 07 Mar 2013 Posts: 53
|
Hello, I send an Input Http Body from a Java class to message Broker :
here's my code :
Code: |
HttpClient client = new DefaultHttpClient();
PostRequest request = new PostRequest(new HttpEndpoint("http",
"192.168.1.246", 7080, "/FormTeleService"));
HttpMessageBody body = new HttpMessageBodyImpl(
new StringHttpMessageBodyPart("<test>Mehdi</test>"));
request.setBody(body);
HttpResponse response = client.send(request);
System.out.println(response);
response.getBody().dump(System.out, "UTF-8", null);
|
and the code of my Java Compute :
Code: |
MbOutputTerminal out = getOutputTerminal("out");
MbMessage message = assembly.getMessage ();
try {
MbMessage outMessage = new MbMessage();
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly, outMessage);
MbElement omroot = outMessage.getRootElement ();
MbElement xmlnsc = omroot.createElementAsLastChild ("XMLNSC");
MbElement valueEl = xmlnsc.createElementAsFirstChild (MbElement.TYPE_VALUE, "ValueS",
message.getRootElement ().getLastChild().getValue().toString());
/*MbElement valueEl = xmlnsc.createElementAsFirstChild (MbElement.TYPE_VALUE, "ValueS",
message.getRootElement ().getFirstElementByPath ("/BLOB/BLOB").getValue().toString());*/
out.propagate (outAssembly);
}
|
It looks correct to me but I don't know why it gives me the 500 error :
Server returned HTTP response code: 500 for URL: http://192.168.1.246:7080/FormTeleService
How can I correct it ? Thank you [/code] |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 12, 2013 7:52 am Post subject: Re: Can't get message input : Error 500 |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mehdiK wrote: |
It looks correct to me but I don't know why it gives me the 500 error |
What does it say in the broker's logs?
What does the user trace you've taken give as the reason for returning a 500 code?
As indicated here, you're going to struggle without some basic background. Attempt to obtain training or better still some mentoring from a WMB person on your site. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mehdiK |
Posted: Tue Mar 12, 2013 8:46 am Post subject: |
|
|
Acolyte
Joined: 07 Mar 2013 Posts: 53
|
Thank you.
it was just a error in my code.
when I add :
Code: |
MbElement valueEl = xmlnsc.createElementAsFirstChild (MbElement.TYPE_VALUE, "Value",
new String ((byte [])message.getRootElement ().getFirstElementByPath ("/BLOB/BLOB").getValue())); |
it's ok, but it returns a result which is like encapsulate but something.
here's the result :
Code: |
<Value>--13d5f7da692
Content-Disposition: form-data; name="Part-0"; filename="Part-0"
<test>Mehdi</test>
--13d5f7da692--
</Value> |
and the only message that I want to get is :
Code: |
<Value>
<test>Mehdi</test>
</Value>
|
(sorry I'm beginner in message broker) |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 12, 2013 10:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mehdiK wrote: |
(sorry I'm beginner in message broker) |
Don't be sorry; this just means you need training and this is not a good place to get it.
Likewise I'm not the best person to be talking about Java but given that:
- if getting the first element of /BLOB/BLOB means what it implies in ESQL then that's by no means right because if you're calling a web service WMB should have placed the XML under the XMLNSC domain for you;
- the getValue won't (or shouldn't) give you anything with actual XML tags in it; one of the reasons your employers bought WMB is because it comes with an XML parser and you don't need to extract values from tags yourself. I'd expect what you posted to have "Mehdi" as the result of a getValue;
Find a mentor. This implies you're not only new, but making basic errors because of this lack of help. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
McueMart |
Posted: Tue Mar 12, 2013 2:08 pm Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Have you tried changing the HTTPInput node to use the XMLNSC parser instead of the BLOB one?
Im not 100% sure this will do what you want though as it looks like the body of your HTTP message is a form-data/multipart POST request and im not quite sure how the XMLNSC parser will deal with that! |
|
Back to top |
|
 |
mehdiK |
Posted: Wed Mar 13, 2013 3:24 am Post subject: |
|
|
Acolyte
Joined: 07 Mar 2013 Posts: 53
|
Yes that's what I will do (I'm intern in IBM so I think that it will be quite possible)
Thank you guys, I'm a little bit confused, I have to learn deeply WMB otherwise I will never be able to do it right.
Thank you. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Mar 13, 2013 4:12 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
mehdiK wrote: |
Thank you guys, I'm a little bit confused, I have to learn deeply WMB otherwise I will never be able to do it right.
|
Good luck with that. Some of us here have been using Broker for at least 10 years and in many places we are only skimming the surface in our understanding of its capabilities.
The first step is to learn what you need to know or importantly, what you don't need to know. For example, if you are never going to use (in your current role) HTTP Nodes then don't try to learn them until you do need to know about them.
You will be able to achieve many tasks by not knowing all there is to know about Broker. From time to time, even the IBM Hursley guys to frequent this place admit that they have learned a few new tricks. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 13, 2013 4:30 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mehdiK wrote: |
Yes that's what I will do (I'm intern in IBM so I think that it will be quite possible) |
If you're inside IBM there is (or used to be) a mechanism to identify such people.
Current IBMers may wish to comment. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 13, 2013 4:37 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Vitor wrote: |
Current IBMers may wish to comment. |
In the sense of confirming or denying the existence of such a program (which could be a cold-induced hallucination) and, if real, how to locate it in the maze of IBM technical web sites and materials.
I was not pimping for volunteers....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|