The SOAP request gets there and fires off the code unit, but the xmlport always fails. I tried to use GETLASTERRORTEXT but it returns nothing. The SOAP returned always has blank values in the xml, just the elements. Some of the lines are pasted from emacs and may have trailing slashes from emacs line breaks. Any thoughts would be greatly appreciated. Here is additional info:
Here is my codeunit:
WebOrderImport(VAR WebOrderImportXMLPort : XMLport "CK Web Order Import") ReturnText : Text[80]
IF WebOrderImportXMLPort.IMPORT THEN BEGIN
ReturnText:='Web Order imported.';
COMMIT;
WebOrdProcessingGCdu.ValidateWebOrders;
WebOrdProcessingGCdu.MakeSalesOrders;
END ELSE
ReturnText:='Web Order Not Imported, Try Again';
Here is the WSDL for the web service it exposes:- <definitions targetNamespace="urn:microsoft-dynamics-schemas/codeunit/WebOrderImportService" xmlns="
http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:microsoft-dynamics-schemas/codeunit/WebOrderImportService">
- <types>
- <schema elementFormDefault="qualified" targetNamespace="urn:microsoft-dynamics-nav/xmlports/WebOrderImport" xmlns="
http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:microsoft-dynamics-nav/xmlports/WebOrderImport">
- <complexType name="CustomField">
- <sequence>
<element minOccurs="0" maxOccurs="unbounded" name="CustomFieldName" type="string" />
<element minOccurs="0" maxOccurs="unbounded" name="CustomFieldValue" type="string" />
</sequence>
</complexType>
- <complexType name="CustomFields" mixed="true">
- <sequence>
<element minOccurs="0" maxOccurs="unbounded" name="CustomField" type="tns:CustomField" />
</sequence>
</complexType>
- <complexType name="Item">
- <sequence>
<element minOccurs="0" maxOccurs="1" name="ItemCode" type="string" />
<element minOccurs="0" maxOccurs="1" name="Variant" type="string" />
<element minOccurs="0" maxOccurs="unbounded" name="Description" type="string" />
<element minOccurs="0" maxOccurs="unbounded" name="Logo" type="string" />
<element minOccurs="0" maxOccurs="1" name="Quantity" type="string" />
<element minOccurs="0" maxOccurs="1" name="Price" type="string" />
<element minOccurs="0" maxOccurs="unbounded" name="CustomFields" type="tns:CustomFields" />
</sequence>
</complexType>
- <complexType name="Items" mixed="true">
- <sequence>
<element minOccurs="1" maxOccurs="unbounded" name="Item" type="tns:Item" />
</sequence>
</complexType>
- <complexType name="order">
- <sequence>
<element minOccurs="1" maxOccurs="1" name="CustomerCode" type="string" />
<element minOccurs="1" maxOccurs="1" name="ShipToContact" type="string" />
<element minOccurs="1" maxOccurs="1" name="ShipToAddress" type="string" />
<element minOccurs="1" maxOccurs="1" name="ShipToAddress2" type="string" />
<element minOccurs="1" maxOccurs="1" name="ShipToCity" type="string" />
<element minOccurs="1" maxOccurs="1" name="ShipToState" type="string" />
<element minOccurs="1" maxOccurs="1" name="ShipToZIP" type="string" />
<element minOccurs="0" maxOccurs="1" name="ShipToCountry" type="string" />
<element minOccurs="1" maxOccurs="1" name="SalesRepCode" type="string" />
<element minOccurs="1" maxOccurs="1" name="ShipViaCode" type="string" />
<element minOccurs="1" maxOccurs="1" name="DeliveryDate" type="string" />
<element minOccurs="1" maxOccurs="1" name="CustomerPONo" type="string" />
<element minOccurs="1" maxOccurs="1" name="SeparateShipment" type="string" />
<element minOccurs="1" maxOccurs="unbounded" name="Items" type="tns:Items" />
</sequence>
</complexType>
<element name="order" type="tns:order" />
</schema>
- <schema elementFormDefault="qualified" targetNamespace="urn:microsoft-dynamics-schemas/codeunit/WebOrderImportService" xmlns="
http://www.w3.org/2001/XMLSchema">
- <element name="WebOrderImport">
- <complexType>
- <sequence>
<element minOccurs="1" maxOccurs="1" name="webOrderImportXMLPort" type="q1:order" xmlns:q1="urn:microsoft-dynamics-nav/xmlports/WebOrderImport" />
</sequence>
</complexType>
</element>
- <element name="WebOrderImport_Result">
- <complexType>
- <sequence>
<element minOccurs="1" maxOccurs="1" name="return_value" type="string" />
<element minOccurs="1" maxOccurs="1" name="webOrderImportXMLPort" type="q2:order" xmlns:q2="urn:microsoft-dynamics-nav/xmlports/WebOrderImport" />
</sequence>
</complexType>
</element>
</schema>
</types>
- <message name="WebOrderImport">
<part name="parameters" element="tns:WebOrderImport" />
</message>
- <message name="WebOrderImport_Result">
<part name="parameters" element="tns:WebOrderImport_Result" />
</message>
- <portType name="WebOrderImportService_Port">
- <operation name="WebOrderImport">
<input name="WebOrderImport" message="tns:WebOrderImport" />
<output name="WebOrderImport_Result" message="tns:WebOrderImport_Result" />
</operation>
</portType>
- <binding name="WebOrderImportService_Binding" type="tns:WebOrderImportService_Port">
<binding transport="
http://schemas.xmlsoap.org/soap/http" xmlns="
http://schemas.xmlsoap.org/wsdl/soap/" />
- <operation name="WebOrderImport">
<operation soapAction="urn:microsoft-dynamics-schemas/codeunit/WebOrderImportService:WebOrderImport" style="document" xmlns="
http://schemas.xmlsoap.org/wsdl/soap/" />
- <input name="WebOrderImport">
<body use="literal" xmlns="
http://schemas.xmlsoap.org/wsdl/soap/" />
</input>
- <output name="WebOrderImport_Result">
<body use="literal" xmlns="
http://schemas.xmlsoap.org/wsdl/soap/" />
</output>
</operation>
</binding>
- <service name="WebOrderImportService">
- <port name="WebOrderImportService_Port" binding="tns:WebOrderImportService_Binding">
<address location="
http://ck-test-1.ck1.dmn:7047/DynamicsNAV/WS/ReplaceWithAPercentEncodedCompanyName/Codeunit/WebOrderImportService" xmlns="
http://schemas.xmlsoap.org/wsdl/soap/" />
</port>
</service>
</definitions>
Here is the SOAP I send
<SOAP-ENV:Envelope xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:microsoft-dynamic\
s-nav/xmlports/WebOrderImport" xmlns:ns2="urn:microsoft-dynamics-schemas/codeunit/WebOrderImportService"><SOAP-ENV:Body><ns2:WebOrderImport><ns2:webOrderImportXMLPort><ns1:order><ns1:CustomerCode>1111</ns1:CustomerCode><ns1:ShipToContact>Chris Grill</ns1:ShipToContact><ns1:ShipToAddress>153 Rosewood Ave</ns1:Sh\
ipToAddress><ns1:ShipToAddress2></ns1:ShipToAddress2><ns1:ShipToCity>Wherever</ns1:ShipToCity><ns1:ShipToState>PA</ns1:ShipToState><ns1:ShipToZIP>55555</n\
s1:ShipToZIP><ns1:ShipToCountry>United States</ns1:ShipToCountry><ns1:SalesRepCode>WEB</ns1:SalesRepCode><ns1:ShipViaCode>UPS Ground</ns1:ShipViaCode><ns1:D\
eliveryDate>1969-12-31</ns1:DeliveryDate><ns1:CustomerPONo>TT3859</ns1:CustomerPONo><ns1:SeparateShipment>0</ns1:SeparateShipment><ns1:Items><ns1:Item><ns1\
:ItemCode>4300</ns1:ItemCode><ns1:Variant>PB-KHA</ns1:Variant><ns1:Description>Visor</ns1:Description><ns1:Quantity>1</ns1:Quantity><ns1:Price>5.0000</ns1:P\
rice></ns1:Item></ns1:Items></ns1:order></ns2:webOrderImportXMLPort></ns2:WebOrderImport></SOAP-ENV:Body></SOAP-ENV:Envelope>'
SOAP returned
<Soap:Envelope xmlns:Soap="
http://schemas.xmlsoap.org/soap/envelope/"><Soap:Body><WebOrderImport_Re\
sult xmlns="urn:microsoft-dynamics-schemas/codeunit/WebOrderImportService"><return_value>Web Order Not Imported, Try Again</return_value><webOrderImportXMLPort><CustomerCode xmlns="ur\
n:microsoft-dynamics-nav/xmlports/WebOrderImport"/><ShipToContact xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrderImport"/><ShipToAddress xmlns="urn:micr\
osoft-dynamics-nav/xmlports/WebOrderImport"/><ShipToAddress2 xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrderImport"/><ShipToCity xmlns="urn:microsoft-dy\
namics-nav/xmlports/WebOrderImport"/><ShipToState xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrderImport"/><ShipToZIP xmlns="urn:microsoft-dynamics-nav/x\
mlports/WebOrderImport"/><ShipToCountry xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrderImport"/><SalesRepCode xmlns="urn:microsoft-dynamics-nav/xmlports\
/WebOrderImport"/><ShipViaCode xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrderImport"/><DeliveryDate xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrder\
Import"/><CustomerPONo xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrderImport"/><SeparateShipment xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrderImpo\
rt"/><Items xmlns="urn:microsoft-dynamics-nav/xmlports/WebOrderImport"><Item><ItemCode/><Variant/><Description/><Logo/><Quantity>0</Quantity><Price>0.00</Pr\
ice><CustomFields/></Item></Items></webOrderImportXMLPort></WebOrderImport_Result></Soap:Body></Soap:Envelope>
Comments
This makes it really easy for any calling process to pump in XML - although you don't get the nice type definitions in the Web Proxy that is created in Visual Studio. But I think it can be much easier to document and sort through problems in the interface if you accept a simpler data type (i.e. BigText).
when I was working through testing of my web service interface (a codeunit which then called an XML Port) it was simple to dump the string that was submitted to NAV to file, review the XML in the file and try to debug where the problem came from.
Epimatic Corp.
http://www.epimatic.com
1. The name of the parameters of a function will start with a lower case character when exposed as a webservice. In this case: webOrderImportXMLPort.
2. The name of the parameter that points to a XMLPort must be exactly match the name of the root element of the XMLPort.
If one of these requirements is missing you might have the behavior that you are struggling with.
My blog