Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enum value not transmitted in soap request

I have a webservice which is referenced in my project by webreference.

Here is the description of an enum in the wsdl file :

<xs:simpleType name="photoIdType">
    <xs:restriction base="xs:string">
       <xs:enumeration value="DRV"/>
       <!-- drivers license -->
       <xs:enumeration value="PAS"/>
       <!-- passport -->
       <xs:enumeration value="STA"/>
       <!-- state ID -->
       <xs:enumeration value="GOV"/>
       <!-- government id -->
       <xs:enumeration value="ALN"/>
       <!-- alien id -->
    </xs:restriction>
</xs:simpleType>

When I have to give a value of this variable, this is my way :

    switch (xRootNode.Element(TagsXML.MG_T_SENDER_PHOTO_ID_TYPE).Value)
     {
     case "ALN":
         sendRequest.senderPhotoIdType = photoIdType.ALN;
         break;
     case "DRV":
         sendRequest.senderPhotoIdType = photoIdType.DRV;
         break;
     case "GOV":
         sendRequest.senderPhotoIdType = photoIdType.GOV;
         break;
     case "PAS":
         sendRequest.senderPhotoIdType = photoIdType.PAS;
         break;
     case "STA":
         sendRequest.senderPhotoIdType = photoIdType.STA;
         break;
   }

Just before I call the method of webservice, I check the value of my enum. The value is here and fine.

But when I check with Fiddler (http packets analyser) the Soap request send to webservice, the photoIdType node is not in !

Do you know if it's a known problem from Visual Studio ? Do you know why the enum value is not sent ?

I can give more informations if you need it.

like image 846
BaptX Avatar asked May 12 '11 16:05

BaptX


1 Answers

I just ran into the same issue and finally tracked down the answer. If you will look at the generated sendRequest definition, you will find a senderPhotoIdTypeSpecified that is a bool. When you set a value for senderPhotoIdType you need to set senderPhotoIdTypeSpecified to true for the value to be serialized and passed.

(tracked the answer down in this ancient thread http://social.msdn.microsoft.com/forums/en-US/netfxremoting/thread/616f67f8-bf11-46e3-b705-41940dcafab6)

like image 180
Larry Smithmier Avatar answered Oct 20 '22 22:10

Larry Smithmier