Welcome Guest! Log in
×

Notice

The forum is in read only mode.
Due to some maintenance operations, stambia.org will be switched to read-only mode during the 13th November. It will be possible to read and download, but impossible to post on the forums or create new accounts. For any question please contact the support team.

Topic-icon Solved How to use a REST webservice using POST method?

More
02 Sep 2016 18:20 #1 by Josserand BRINON
Josserand BRINON created the topic: How to use a REST webservice using POST method?
Hi,

We want to invoke a REST webservice with Stambia.
We've seen that it is documented on this URL : www.stambia.org/doc/65-technologies/web-...-an-http-get-service
The tutorial explains how to do it with the GET method, but we need to use the POST method.

As mentionned in the "REVERSING THE RESPONSE IN AN OUTPUT PARAMETER" part, we must reverse a XML file made from a response, and copy/paste its first Sequence to the Output node of the wsdl metadata.

We guess that, for the POST method, we can do the same procedure for the Input definition.

We have the following structure :


You can notice that we have renamed the Input part and the Output part with the root XML node.

Then, we tried to execute the mapping.
Here is the error we are facing, on the step "Call WebServices":
org.xml.sax.SAXException: Error on path: /almerys/Almerys_findsaleslist/findsaleslist_port/findsaleslist/output/genericresponse
java.lang.NullPointerException
	at com.indy.engine.actionCodes.XmlToWsdlActionCodeI$SimpleContentHandler.endElement(SourceFile:649)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.indy.engine.actionCodes.XmlToWsdlActionCodeI.executeSimpleCode(SourceFile:155)
	at com.indy.engine.action.common.ActionCodeTypeI.executeCode(SourceFile:1646)
	at com.indy.engine.action.common.ActionCodeTypeI.run(SourceFile:1805)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
	at com.indy.engine.actionCodes.a.g.d(SourceFile:214)
	at com.indy.engine.actionCodes.a.g.e(SourceFile:466)
	at com.indy.engine.actionCodes.a.g.c(SourceFile:481)
	at com.indy.engine.actionCodes.XmlToWsdlActionCodeI$SimpleContentHandler.a(SourceFile:762)
	at com.indy.engine.actionCodes.XmlToWsdlActionCodeI$SimpleContentHandler.endElement(SourceFile:628)
	... 12 more

We don't know how to solve it.
Any help?
Attachments:
More
05 Sep 2016 09:11 #2 by Thomas BLETON
Thomas BLETON replied the topic: How to use a REST webservice using POST method?
Hi,
Did you map the root node of the service ?
See the example from the article , the first node is mapped. This is necessary.
More
05 Sep 2016 12:27 - 05 Sep 2016 12:29 #3 by Josserand BRINON
Josserand BRINON replied the topic: How to use a REST webservice using POST method?
Yes, we have mapped the root node.

Here is the screenshot of our mapping.




Our first error disappeared by modifying the metadata. We guess there was a problem in the metadata.
So, we recreated the both Input and Output entries.

We have added by ourselves the root node as a new Sequence + Element.
Here is the new metadata view:



Now, the file generated in the "Sent Messages Folder" is adapted to what we need.

.../...
Attachments:
Last Edit: 05 Sep 2016 12:29 by Josserand BRINON.
More
05 Sep 2016 12:28 - 05 Sep 2016 12:30 #4 by Josserand BRINON
Josserand BRINON replied the topic: How to use a REST webservice using POST method?
.../...

Now, we have two issues.

1/ the file int "Received Messages Forder" shows us:
La requ?te n?cessite une authentification HTTP (Full authentication is required to access this resource).
Maybe we have not filled well the Security parameters of the Port... Is it enough to fill Username and Password for a Basic Auth (as used in Postman)?

2 / there is a new error on the execution, on the "Load Tables" step:
java.lang.NumberFormatException: Zero length BigInteger
	at java.math.BigInteger. init (BigInteger.java:296)
	at java.math.BigInteger. init (BigInteger.java:476)
	at javax.xml.bind.DatatypeConverterImpl._parseInteger(DatatypeConverterImpl.java:78)
	...


Are these 2 issues linked?
Last Edit: 05 Sep 2016 12:30 by Josserand BRINON.
More
05 Sep 2016 14:27 #5 by Josserand BRINON
Josserand BRINON replied the topic: How to use a REST webservice using POST method?
Something is strange: the file created on the "Sent Messages Folder" contents the URL with the method, concatenated with "null"
https://www.<hiddenForTheForum>.com/esign/restserver/restapi/facade/auth/findsaleslistnull
Something is wrong, but we don't know what...
More
05 Sep 2016 15:10 - 28 Sep 2016 16:07 #6 by Thomas BLETON
Thomas BLETON replied the topic: How to use a REST webservice using POST method?
Can you send an "Export models and depencies" of your mapping, to the support team?
This deserves a closer analysis which cannot be done on the forum.
thanks
Last Edit: 28 Sep 2016 16:07 by Thomas BLETON.
More
06 Sep 2016 12:20 #7 by Josserand BRINON
Josserand BRINON replied the topic: How to use a REST webservice using POST method?
We have shared our different issues with the Support.
The conclusions are:

1/ the URL is well returned on the file .in created on the "Sent Messages Folder" if
- we fill the Port with the URL and without the method: https://www.<hiddenForTheForum>.com/esign/restserver/restapi/facade/auth/
- we fill the Operation with the method: findsaleslist

2/ We had an athentication issue.
It has been solved by replacing the Security parameters of the Port with the Http Header Properties of the Operation.
The value has been found on the Headers part of Postman. It is something like:
Authorization:Basic <base64string>

3/ The error "Zero length BigInteger" mentionned above has not been solved yet, but got round.
The problem was on an integer field. We switched the metadata to string.
It works.

Thank you again Thomas :)
More
24 Oct 2017 15:15 #8 by Thomas BLETON
Thomas BLETON replied the topic: How to use a REST webservice using POST method?
For your information, regarding point#2 : the Runtime 17.3.3 and above now generates the proper HTTP header from the metadata's security parameters.