Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
8
Erster Beitrag:
vor 1 Jahr, 9 Monaten
Letzter Beitrag:
vor 1 Jahr, 9 Monaten
Beteiligte Autoren:
Peter Holemans, Alexandre Leclerc, Bart VDE

WX: Consume Web Service - String parameter

Startbeitrag von Peter Holemans am 18.08.2016 12:34

Hi,

I'm working on a SharePoint interface using the SP web services.
This works pretty OK but I'm having a problem where the WX runtime tries to be too smart and breaks the XML being send.

It's likely that I am missing something and that there is an XML standard to force data in an XML node NOT to be altered in any way by a parsing engine. I can't know it all of course...

Anyway, here's the story:
1. The ISSUE:
The WX runtime tries to be too intelligent and parses an XML body passed in a webservice parameter of string type into text without reserved xml characters.

E.g. "< Query > becomes & ltQuery& gt…

2. The QUESTION:
Is there a W-Language method/option or an XML attribute where we can force that the WX webservice execution engine does not parse xml text into text without reserved xml characters for a web service parameter of string type?
[(,&,…) becomes (& lt,& gt,& amp,…) etc.]

As we need to pass an XML into a SharePoint parameter which is defined as a string parameter.

3. EXAMPLE: Sharepoint GetListItems Webservice
SOAP 1.2
The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.

POST /_vti_bin/lists.asmx HTTP/1.1
Host: test.hamon.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

< soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"; >
< soap12:Body >
< GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"; >
< listName > string< /listName >
< viewName > string< /viewName >
< query > string< /query >
< viewFields > string< /viewFields >
< rowLimit > string< /rowLimit >
< queryOptions > string< /queryOptions >
< webID > string< /webID >
< /GetListItems >
< /soap12:Body >
< /soap12:Envelope >


Imported in WX as a web service...
As you can see the Query parameter is defined as a string by the Sharepoint wsdl contract above but in practice it needs to be completed with an XML itself that contains the query in xml format.

4. Execution in WX (Simplified)
This is how it looks in WX (simplified test block):

...
//WS INIT Stuff
//Set Web service address and authentication
Lists..Address = pWSAddress
Lists..Authentication = auNegotiate
Lists..User = pWSUserName
Lists..Password = pWSUserPassword
Lists..MethodHTTP = httpPost
Lists..IgnoreError = httpIgnoreExpiredCertificate+httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreRedirection
...
//DECLARE

SPLst is Lists.GetListItems
SPWSResponse is Lists.GetListItemsResponse

//SET PARAMS
SPLst.listName = "AP"
SPLst.query = [
< Query >
< Where >
< Eq >
< FieldRef Name='ProjectID' / >
< Value Type='Text' > a< /Value >
< /Eq >
< /Where >
< /Query >
]

SPWSResponse = Lists.GetListItems(SPLst)

//Return Result
IF ErrorOccurred() THEN
ErrMsg:AddToList(pErrLst,soErrorMessage::EM_ERROR,"WEBSERVICE","Error encountered. Contact your supplier if the problem persists.",ErrorInfo(errMessage))
WXApplication::LogError(pErrLst)
RESULT (False, WSResponse)
ELSE
RESULT (True, WSResponse)
END


5. Response in WX returned by the Sharepoint server
The following error was returned by the service by hErrorInfo():
Code: 'Server'
Message: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

6. Sharepoint server logs
If we look on the server, we can trace the execution of the SOAP request which is broken at the point where the WX runtime replaced < by <:
< ?xml version="1.0" encoding="UTF-8"?> < SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">; < SOAP-ENV:Header/> < SOAP-ENV:Body> < ns1:GetListItems xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/"; > < ns1:listName> AP< /ns1:listName > < ns1:query > <
SOAP exception: System.Runtime.InteropServices.COMException (0x82000000): Element < Query > of parameter query is missing or invalid.…

7. And what if we use SOAPPrepare to get the XML to send manually?
SOAPPrepare() works fine as well but does the exact same trick...
This is the XML string returned by SOAPPrepare for the above WX code.

As you can see the < Query > element is parsed as well by the WX Runtime Engine as non xml text...


< ?xml version="1.0" encoding="UTF-8"? >
< SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >
< SOAP-ENV:Header/ >
< SOAP-ENV:Body >
< ns1:GetListItems xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/"; >
< ns1:listName > AP< /ns1:listName >
< ns1:query >
& lt;Query& gt;& #13;
& lt;Where& gt;& #13;
& lt;Eq& gt;& #13;
& lt;FieldRef Name='ProjectID' /& gt;& #13;
& lt;Value Type='Text'& gt;a& lt;/Value& gt;& #13;
& lt;/Eq& gt;& #13;
& lt;/Where& gt;& #13;
& lt;/Query& gt;
< /ns1:query >

< /ns1:GetListItems >
< /SOAP-ENV:Body >
< /SOAP-ENV:Envelope >


8. CONCLUSION
The WX runtime has altered the < Query > < Where >… string into non xml text & lt;Query& gt;& & lt;Where& gt;
This is an unwanted behaviour.

Therefore we would like to know if it is possible in W-Language or by a W3 XML standard to force the WX runtime not to alter an xml body if it passed intentionally into web service parameter of string type.

TIA all for any feedback that leads to a solution !

Cheers,

Peter Holemans 

PS: Never mind the extra spaces etc. in the XML files as I had to alter this in order for it to display reasonably within this forum software

Antworten:

Nobody?

von Peter Holemans - am 22.08.2016 08:11
Hi Peter,

So, if I understand, the Lists.GetListItems structure does not include the xml elements definition for the < query > key and it must be built on the fly?

The only thing I would see right now is to build the XML query manually (using an XML variable if you want) and then send it with the HTTP command (or the SOAP* commands, which was the old way to do it). But in doing so you lose all the advantages of the SOAP features in WinDev. Yet you can use an XML variable to process the answer. This would work too, but some more checks and coding would be required.

Otherwise I think WX will always try to parse the < query > content since it assumes it is text, by definition, and not an additional layer of XML data. It would be nice to be able to do some “XML injection”; this would be a nice feature in your case.

There might be a way, but unfortunately, as far as I am concerned, maybe only the free technical support team might have a solution for that.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 22.08.2016 12:28
Hi again Peter,

Yep, in the help they say that the SOAP* commands can be used to “inject” some additional data in a soap query. You might be interested to take a look if it is possible in your case: section “Advanced operations of the XML stream of the Webservice” from the section “Using a Webservice”.

http://doc.windev.com/en-US/?3086001#using_webservice_ELTTEXTE000566

Maybe the section just after that one will also be of interest to you: “Special case: the Webservice returns a result whose type is not recognized by WINDEV, WEBDEV and WINDEV Mobile”.

I hope this helps.

Best regards,
Alexandre Leclerc

Edit 1: Typo corrections.

von Alexandre Leclerc - am 22.08.2016 12:34
Many thanks Alexandre for the follow-up !
This is much appreciated :-)

I'll have a look right away at the possible solutions in the SOAP commands you've sent...
Indeed, if we have to build our full XML flow ourselves because of this limitation in WX (no XML injection), I might need to switch over to Visual Studio for this as that will be for sure 10 times faster in this case...

Cheers and thanks again !

Peter Holemans


PS: I also raised a call with TechSupport at PCSoft last Wednesday around noon for this but no answer to date...
(So far for the 24 to 48 hours response time :-( But I hope they're investigating it thoroughly and it isn't dangling in the support queue somewhere)

von Peter Holemans - am 22.08.2016 14:13
Hi Peter,

I hope you will find a nice solution.

As for the delays, this is 24 to 48 hours of working hours. This means 3 to 6 days at 8 hours per day. Right now (July and August) they work a little bit slower because these are the vacations. So they have reduced staff. My guess is that the request is pending. Usually you will have an answer that they will look into it if they do not know an immediate solution for you.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 22.08.2016 15:35
Hi,

Maybe you can insert a CDATA tag in where you can put your data that not should be interpreted as XML markup

Regards,
Bart

von Bart VDE - am 22.08.2016 18:41
Hi Bart,

Thanks for the suggestion but I already tried that and the CDATA tag doesn't make any difference during the execution (unless I inserted it wrongly of course :-O )

Cheers,

Peter Holemans

von Peter Holemans - am 22.08.2016 20:26
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.