SOAP request - local wsdl file

rhpnt
Member Posts: 688
Hi everyone,
stuck again. I have to send a SOAP request to a web server using a local WSDL file. I read all existing threads on this forum and tried everything but my web/soap/html programming skills are simply not enough. The examples in the threads I read all assume that the wsdl file is located on the ws server I have mine stored locally (the service provider insists).
The request example provided by the service provider looks like this:
I've no idea how to map that to NAV...
Any help would be greatly appreciated.
stuck again. I have to send a SOAP request to a web server using a local WSDL file. I read all existing threads on this forum and tried everything but my web/soap/html programming skills are simply not enough. The examples in the threads I read all assume that the wsdl file is located on the ws server I have mine stored locally (the service provider insists).
The request example provided by the service provider looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v001="http://www.someprodvider.com/dspone/ordercheck-if/V001"> <soapenv:Header> <v001:messageContext> <v001:credentials> <v001:user>xxx</v001:user> <v001:password>xxx</v001:password> </v001:credentials> <v001:correlationID>Test_001</v001:correlationID> </v001:messageContext> </soapenv:Header> <soapenv:Body> <v001:orderCheckRequest> <v001:product> <v001:name>CreditCheckBusiness</v001:name> <v001:country>DEU</v001:country> <v001:proofOfInterest>ABK</v001:proofOfInterest> </v001:product> <v001:searchedAddress> <v001:legalForm>COMPANY</v001:legalForm> <v001:address> <v001:name>SomeCompanyName</v001:name> <v001:location> <v001:street>Kaiserstrasse</v001:street> <v001:house>217</v001:house> <v001:city>Karlsruhe</v001:city> <v001:zip>76133</v001:zip> </v001:location> </v001:address> </v001:searchedAddress> </v001:orderCheckRequest> </soapenv:Body> </soapenv:Envelope>
I've no idea how to map that to NAV...
Any help would be greatly appreciated.
0
Answers
-
I hope this Sample can help you learn SOAP in NAV
OBJECT Codeunit 50012 HTTP/Webservice Currency Rate { OBJECT-PROPERTIES { Date=09.09.11; Time=13:13:28; Modified=Yes; Version List=WS1.01; } PROPERTIES { OnRun=BEGIN Http; END; } CODE { VAR TempBLOB@1101502000 : Record 99008535; TempInstream@1101502001 : InStream; PROCEDURE Http@1000000001(); VAR locautXmlHttp@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F16-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.XMLHTTP"; locautXmlDoc@1000000001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"; Success@1101502000 : Boolean; BEGIN CREATE(locautXmlDoc); locautXmlDoc.async := FALSE; //locautXmlDoc.load('C:\TEMP\Input.xml'); GenerateXMLandRate('USD','RUB'); TempBLOB.CALCFIELDS(Blob); TempBLOB.Blob.CREATEINSTREAM(TempInstream); locautXmlDoc.load(TempInstream); CREATE(locautXmlHttp); locautXmlHttp.open('POST','http://www.webservicex.net/CurrencyConvertor.asmx',0); locautXmlHttp.setRequestHeader('Content-type','application/soap+xml; charset=utf-8'); locautXmlHttp.setRequestHeader('SOAPAction','http://www.webserviceX.NET/ConversionRate'); locautXmlHttp.send(locautXmlDoc); locautXmlDoc.loadXML(locautXmlHttp.responseText); locautXmlDoc.async := TRUE; //locautXmlDoc.save('C:\TEMP\temp.xml'); IF locautXmlHttp.status = 200 THEN MESSAGE('%1', locautXmlDoc.documentElement.selectSingleNode('soap:Body/ConversionRateResponse/ConversionRateResult').text) ELSE MESSAGE('%1', locautXmlHttp.status); { Input.XML: <?xml version="1.0" encoding="utf-8"?> <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> <ConversionRate xmlns="http://www.webserviceX.NET/"> <FromCurrency>RUB</FromCurrency> <ToCurrency>USD</ToCurrency> </ConversionRate> </soap12:Body> </soap12:Envelope> } END; LOCAL PROCEDURE GenerateXMLandRate@1000000009(FromCurrency@1000000004 : Code[10];ToCurrency@1000000005 : Code[10]); VAR Ostream@1000000000 : OutStream; MyXmlPort@1000000002 : XMLport 50000; BEGIN CLEAR(TempBLOB); TempBLOB.Blob.CREATEOUTSTREAM(Ostream); MyXmlPort.SetCurrencyCodes(FromCurrency,ToCurrency); MyXmlPort.SETDESTINATION(Ostream); MyXmlPort.EXPORT; END; BEGIN END. } } OBJECT Codeunit 50013 HTTP/Webservice Weather { OBJECT-PROPERTIES { Date=09.09.11; Time=13:12:27; Modified=Yes; Version List=WS1.01; } PROPERTIES { OnRun=BEGIN Http; END; } CODE { VAR TempBLOB@1101502000 : Record 99008535; TempInstream@1101502001 : InStream; OStr@1101502002 : OutStream; PROCEDURE Http@1000000001(); VAR locautXmlHttp@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F16-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.XMLHTTP"; locautXmlDoc@1000000001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"; locautXmlElem@1101502002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF86-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMElement"; locautXmlDoc2@1101502001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"; Success@1101502000 : Boolean; BEGIN CREATE(locautXmlDoc); locautXmlDoc.async := FALSE; GenerateXMLandRate('Russian Federation','Moscow / Vnukovo'); TempBLOB.CALCFIELDS(Blob); TempBLOB.Blob.CREATEINSTREAM(TempInstream); locautXmlDoc.load(TempInstream); CREATE(locautXmlHttp); locautXmlHttp.open('POST','http://www.webservicex.net/globalweather.asmx',0); locautXmlHttp.setRequestHeader('Content-type','application/soap+xml; charset=utf-8'); locautXmlHttp.setRequestHeader('SOAPAction','http://www.webserviceX.NET/GetWeather'); locautXmlHttp.send(locautXmlDoc); locautXmlDoc.load(locautXmlHttp.responseXML); locautXmlDoc.save('C:\TEMP\temp.xml'); IF locautXmlHttp.status = 200 THEN BEGIN CREATE(locautXmlDoc2); locautXmlDoc2.async := FALSE; locautXmlDoc2.loadXML(locautXmlDoc.documentElement.selectSingleNode('soap:Body/GetWeatherResponse/GetWeatherResult').text); //locautXmlDoc2.save('C:\TEMP\temp2.xml'); MESSAGE('%1', locautXmlDoc2.documentElement.selectSingleNode('/CurrentWeather/Temperature').text); END ELSE MESSAGE('%1', locautXmlHttp.status); { Input.XML: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetWeather xmlns="http://www.webserviceX.NET"> <CityName>Moscow / Vnukovo</CityName> <CountryName>Russian Federation</CountryName> </GetWeather> </soap:Body> </soap:Envelope> } END; LOCAL PROCEDURE GenerateXMLandRate@1000000009(CountryName@1000000004 : Text[30];CityName@1000000005 : Text[30]); VAR Ostream@1000000000 : OutStream; MyXmlPort@1000000002 : XMLport 50001; BEGIN CLEAR(TempBLOB); TempBLOB.Blob.CREATEOUTSTREAM(Ostream); MyXmlPort.SetCountryCodes(CountryName,CityName); MyXmlPort.SETDESTINATION(Ostream); MyXmlPort.EXPORT; END; BEGIN END. } } OBJECT XMLport 50000 XML Currency Exchange { OBJECT-PROPERTIES { Date=08.09.11; Time=17:48:21; Modified=Yes; Version List=WS1.01; } PROPERTIES { Encoding=UTF-8; OnInitXMLport=BEGIN xmlnsxsi:='http://www.w3.org/2001/XMLSchema-instance'; xmlnsxsd:='http://www.w3.org/2001/XMLSchema'; xmlnssoap12:='http://www.w3.org/2003/05/soap-envelope'; xmlns := 'http://www.webserviceX.NET/'; FromCurrency := 'USD'; ToCurrency := 'EUR'; END; OnPreXMLport=BEGIN IF (FromCurrency = '') OR (ToCurrency = '') THEN ERROR('Please set currency codes first'); END; } ELEMENTS { { [{375EFE96-EDD8-4598-9269-141E48BE3650}]; ;soap12:Envelope ;Element ;Text } { [{571C3E3F-9F7F-432C-B771-DB0817F0553F}];1 ;xmlns:xsi ;Attribute;Text ; VariableName=xmlnsxsi } { [{D0FF1893-D99E-4EEC-8137-16E49C496160}];1 ;xmlns:xsd ;Attribute;Text ; VariableName=xmlnsxsd } { [{E844CCA2-3B72-4C69-B8CD-452C5C98E8CD}];1 ;xmlns:soap12 ;Attribute;Text ; VariableName=xmlnssoap12 } { [{B7EB8F33-9C41-4E24-B7FE-F5635B0C8D62}];1 ;soap12:Body ;Element ;Text } { [{13375059-BFF8-43AB-A523-7B7C215AA4EB}];2 ;ConversionRate ;Element ;Text } { [{9D056E40-E69F-4543-A64E-09D6CED6EA57}];3 ;xmlns ;Attribute;Text ; VariableName=xmlns } { [{6358A5A6-0ADE-4B58-AE5F-0B79C6F414CF}];3 ;FromCurrency ;Element ;Text ; VariableName=FromCurrency } { [{0C05CF74-B501-496C-BF13-47A0740F12F6}];3 ;ToCurrency ;Element ;Text ; VariableName=ToCurrency } } EVENTS { } CODE { PROCEDURE SetCurrencyCodes@1000000000(LFromCurrency@1000000000 : Code[10];LToCurrency@1000000001 : Code[10]); BEGIN FromCurrency := LFromCurrency; ToCurrency := LToCurrency; END; BEGIN END. } } OBJECT XMLport 50001 XML Weather { OBJECT-PROPERTIES { Date=09.09.11; Time=13:09:56; Modified=Yes; Version List=WS1.01; } PROPERTIES { Encoding=UTF-8; OnInitXMLport=BEGIN xmlnsxsi:='http://www.w3.org/2001/XMLSchema-instance'; xmlnsxsd:='http://www.w3.org/2001/XMLSchema'; xmlnssoap:='http://schemas.xmlsoap.org/soap/envelope/'; xmlns := 'http://www.webserviceX.NET'; CountryName := 'Russian Federation'; CityName := 'Moscow / Vnukovo'; END; OnPreXMLport=BEGIN IF CountryName = '' THEN ERROR('Please set country code first'); END; } ELEMENTS { { [{375EFE96-EDD8-4598-9269-141E48BE3650}]; ;soap:Envelope ;Element ;Text } { [{571C3E3F-9F7F-432C-B771-DB0817F0553F}];1 ;xmlns:xsi ;Attribute;Text ; VariableName=xmlnsxsi } { [{D0FF1893-D99E-4EEC-8137-16E49C496160}];1 ;xmlns:xsd ;Attribute;Text ; VariableName=xmlnsxsd } { [{E844CCA2-3B72-4C69-B8CD-452C5C98E8CD}];1 ;xmlns:soap ;Attribute;Text ; VariableName=xmlnssoap } { [{B7EB8F33-9C41-4E24-B7FE-F5635B0C8D62}];1 ;soap:Body ;Element ;Text } { [{13375059-BFF8-43AB-A523-7B7C215AA4EB}];2 ;GetWeather ;Element ;Text } { [{9D056E40-E69F-4543-A64E-09D6CED6EA57}];3 ;xmlns ;Attribute;Text ; VariableName=xmlns } { [{6358A5A6-0ADE-4B58-AE5F-0B79C6F414CF}];3 ;CityName ;Element ;Text ; VariableName=CityName } { [{0C05CF74-B501-496C-BF13-47A0740F12F6}];3 ;CountryName ;Element ;Text ; VariableName=CountryName } } EVENTS { } CODE { PROCEDURE SetCountryCodes@1000000000(LCountryName@1000000000 : Text[30];LCityName@1000000001 : Text[30]); BEGIN CityName := LCityName; CountryName := LCountryName; END; BEGIN END. } }
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions