<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://sqlserver/customer"> <soapenv:Header/> <soapenv:Body> <cus:GetLuckyNumber> <cus:customerID>?</cus:customerID> </cus:GetLuckyNumber> </soapenv:Body> </soapenv:Envelope>
//setup the temporary table so that we can handle the XML without saving it to disk first //create a couple of streams to transfer the data in and out of the BLOB field CLEAR(TempTable); TempTable.Blob.CREATEINSTREAM(InStr); TempTable.Blob.CREATEOUTSTREAM(OutStr); //the request XMLport fills the BLOB with the XML message CLEAR(XP1); // BMS 20/02/2009 - Set the CustomerID. XP1.AssignCustomerID(lvarCustID); XP1.SETDESTINATION(OutStr); XP1.EXPORT; //load the message into the XML automation variable IF ISCLEAR(XMLDoc) THEN CREATE(XMLDoc); XMLDoc.load(InStr); //this is for diagnostics only, so you can see what the XMLport actually produced XMLDoc.save('C:\Temp\XMLRequest.txt'); //create the HTTP connector IF ISCLEAR(XMLHttpConn) THEN CREATE(XMLHttpConn); //tell it where the web service is located XMLHttpConn.open('POST','http://sqlserver/sql',FALSE, 'username', 'password'); //set some values in the request header depending on what the service requires XMLHttpConn.setRequestHeader('Host','sqlserver'); XMLHttpConn.setRequestHeader('SOAPAction','http://sqlserver/customerGetLuckyNumber'); XMLHttpConn.setRequestHeader('Content-type','text/xml;charset=UTF-8'); XMLHttpConn.setRequestHeader('Content-Length','299'); //actually send the message XMLHttpConn.send(XMLDoc); //get the response XMLDoc.load(XMLHttpConn.responseXML); //tell us if we got an error (it is 200 because the response definition said "200 OK") IF XMLHttpConn.status <> 200 THEN BEGIN MESSAGE('Status %1 %2',XMLHttpConn.status,XMLHttpConn.statusText); EXIT; END; //this is for diagnostics only, so you can see what you got back XMLDoc.save('C:\Temp\XMLResponse1.xml'); //take away the namespaces RemoveNamespace(XMLDoc,XMLDoc); //this is for diagnostics only, so you can see what it looks like after the namespaces have gone XMLDoc.save('C:\Temp\XMLResponse2.xml'); //fill the BLOB with the response XML XMLDoc.save(OutStr); //the response XMLport reads the data from the BLOB and processes it CLEAR(XP2); XP2.SETSOURCE(InStr); XP2.IMPORT;
DROP ENDPOINT sql_CustomerLuckyNumber; GO CREATE ENDPOINT sql_CustomerLuckyNumber STATE = STARTED AS HTTP( PATH = '/sql', AUTHENTICATION = ( INTEGRATED ), PORTS = ( CLEAR ), SITE = '*' ) FOR SOAP ( WEBMETHOD 'http://sqlserver/customer'.'GetLuckyNumber' (name='OPAL.dbo.GetCustomerLuckyNumber', SCHEMA=STANDARD ), WSDL = DEFAULT, SCHEMA = STANDARD, DATABASE = 'OPAL', NAMESPACE = 'http://sqlserver/customer/' ); GO
Answers
http://mibuso.com/blogs/ara3n/2008/05/1 ... bservices/
It shows you how to consume an endpoint webservice in nav. Hope this helps.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I am back at work tomorrow so I will give it a try then, thanks.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I implemented your code, ara3n, and it more-or-less worked right away. So then I looked at where yours was different to mine, when I came across this:
The double quotes inside the namespace! That sorted it right out. Now I have to try and sort out pulling just the answer from all this XML hehe.
Thanks!
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Ahh so there is. I have run into another problem in the meantime, but since technically this issue is solved and my problem, although related, is another issue, I should probably go and make another thread. Hopefully this one can be solved as well!