2

How to get the HTTP-Status from a webMethods com.wm.net.NetException?

Is there a way to get the http status code from within the catch block of a java service after calling the pub.client:http service?

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
eventhorizon
  • 2,977
  • 8
  • 33
  • 57

1 Answers1

0

If you invoke the pub.client:http from within a flow service, you'll notice that it doesn't throw an exception. For example, a "403 Forbidden" error, will not throw an exception. Instead, it will output to the pipeline a header document.

enter image description here

Within the header document you will find the http status:

enter image description here

When you invoke pub.client:http from within a java service then the invocation is suppose to return an IData object. From that object you should be able to extract the status field using IDataUtil.

So, when you evaluate that the status is not OK, you can throw a ServiceException which will be caught by the flow try/catch.

Hope this helps!

TchiYuan
  • 4,258
  • 5
  • 28
  • 35
  • Sorry, but this seems to be wrong. With your described behavior I would be totally satisfied, but in Webmethods 9.8 you get an exception instead of a 401 status... – eventhorizon Nov 23 '15 at 19:49
  • WebMethods 9.5 here. Try doing it in a flow service as described. Use this forbidden url http://www.checkupdown.com/accounts/grpb/B1394343/ .Are you sure you are getting an exception ? – TchiYuan Nov 23 '15 at 23:00
  • Will try it again tomorrow. – eventhorizon Nov 24 '15 at 07:49