5

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.

1 Answer 1

10

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)

2
  • Thank you, you just saved me a lot of time and pain!
    – GWTNewbie
    Aug 25, 2011 at 11:57
  • 1
    Thanks for the answer .. it save my time. Feb 13, 2016 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.