枚举值不在soap请求中传输

Bap*_*ptX 5 enums soap web-services visual-studio-2010

我有一个webservice,在我的项目中通过webreference引用.

以下是wsdl文件中枚举的说明:

<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>
Run Code Online (Sandbox Code Playgroud)

当我必须给出这个变量的值时,这是我的方式:

    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;
   }
Run Code Online (Sandbox Code Playgroud)

就在我调用webservice的方法之前,我检查了我的枚举的值.价值在这里,很好.

但是当我用Fiddler(http数据包分析器)检查Soap请求发送到webservice时,photoIdType节点不在!

你知道这是Visual Studio的一个已知问题吗?你知道为什么没有发送枚举值吗?

如果需要,我可以提供更多信息.

Lar*_*ier 9

我刚遇到同样的问题,最后找到了答案.如果您将查看生成的sendRequest定义,您会发现senderPhotoIdTypeSpecified它是一个bool.当您设置一个值senderPhotoIdType,你需要设置senderPhotoIdTypeSpecifiedtrue的值被序列化并通过.

(在这个古老的帖子中找到答案http://social.msdn.microsoft.com/forums/en-US/netfxremoting/thread/616f67f8-bf11-46e3-b705-41940dcafab6)