I’m trying to call a Web service via SOAP (https://modelviewers.pilotfishtechnology.com/modelviewers/OTA/model/Format.OTA_HotelRoomListRQ.html).
My code, so far, is:
var OTA_HotelRoomListRQ = new MyMapping.OTA_HotelRoomListRQ()
{
TimeStamp = DateTime.Now,
Version = 1,
HotelRoomLists = new HotelRoomListType[] { new HotelRoomListType { HotelCode = "12345" } }
};
MyMapping.OTA_HotelRoomListRS OTA_HotelRoomListRS = null;
var test = MyMapping_PortTypeClient.ReadRoomTypes(securityHeaderType, ref MessageID, ref to, ref from, ref action, OTA_HotelRoomListRQ, out OTA_HotelRoomListRS);
I get the following error:
There was an error in serializing one of the headers in message ReadRoomTypesRequest: 'Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'MySolution.ReadMapping.VendorMessageType[]' to 'MySolution.ReadMapping.VendorMessageType'
error CS0030: Cannot convert type 'MySolution.ReadMapping.VendorMessageType[]' to 'MySolution.ReadMapping.VendorMessageType'
error CS0029: Cannot implicitly convert type 'MySolution.ReadMapping.VendorMessageType' to 'MySolution.ReadMapping.VendorMessageType[]'
error CS0029: Cannot implicitly convert type 'MySolution.ReadMapping.VendorMessageType' to 'MySolution.ReadMapping.VendorMessageType[]'
'. Please see InnerException for more details.
I don’t understand what I’m missing and what the error references.
Try 1: A known issue with WSDL.exe can cause a proxy class to be generated incorrectly if an array of complex type includes an element that's also an array of complex type and for which only one element exists.
There are three workarounds available:
You can generate the proxy class manually by using WSDL.exe and then change the proxy class in which the data type was inappropriately created as a two-dimensional array (for example, CustomType[][]) so that it's a single-dimensional array (for example, CustomType[]).
You can change the data type in the desired Web Services Description Language (WSDL) so that a second, optional element is included in the definition. You can do this by adding an element such as the following example: <xs:element minOccurs="0" name="dummyElement" nillable="true" type="xs:string"/>
You can change the complex type in the desired WSDL so that the boundary attributes are part of the complex type instead of being part of the element. (That is, you can move the minOccurs and maxOccurs attributes to the complex type and then remove them from the element.)
See: Unable to generate a temporary class (result=1) error when executing the Invoke Web Services object
Try 2: XML Serialisation works by generating code to perform the serialisation. This is done in a temporary assembly created for that purpose the first time it is needed.
However this relies on being able to write the assembly to disk.1
Your options are either to:
See: System.InvalidOperationException: Unable to generate a temporary class (result=1)