从CompactFramework客户端使用Web服务

时间:2009-01-05 15:28:47

标签: c# web-services compact-framework

我正在尝试调用这样的webservice方法:

myService.Register("mystring");

webmethod定义只是:

[WebMethod]
public void Register(string s)
{
}

但是我收到以下System.InvalidOperationException:

“不期望使用System.String类型。使用XmlInclude或SoapInclude属性指定静态未知的类型。”


   at System.Xml.Serialization.AccessorCollection.findAccessor(Type t)
   at System.Xml.Serialization.XmlSerializationWriter.EnqueueMember(MemberValueCollection members, LogicalMemberValue member, SerializationQueue attributes, SerializationQueue elements, Object fetcherTarget, String parentElementNamespace)
   at System.Xml.Serialization.XmlSerializationWriter.EnqueueMembers(MemberValueCollection members, SerializationQueue attributes, SerializationQueue elements, Object fetcherTarget, String parentElementNamespace)
   at System.Xml.Serialization.XmlSerializationWriter.SerializeComplexAsElement(LogicalType serializeAs, Accessor accessor, Object value, SerializationQueue delayedWork, Boolean recursiveCall, Boolean requiresTypeAttr, XmlSerializerNamespaces serializerNs)
   at System.Web.Services.Protocols.SoapMessageFormatter.SerializeComplexAsElement(LogicalType serializeAs, Accessor accessor, Object value, SerializationQueue delayedWork, Boolean recursiveCall, Boolean requiresTypeAttr, XmlSerializerNamespaces ns)
   at System.Xml.Serialization.XmlSerializationWriter.SerializeAsElement(Accessor accessor, Object value, Object fetcherTarget, SerializationQueue delayedWork, Boolean recursiveCall, Boolean schemaReqTypeAttr, XmlSerializerNamespaces serializerNs)
   at System.Xml.Serialization.XmlSerializationWriter.serializeMembers(SerializationQueue queue, SerializationQueue delayedWork, Boolean recursiveCall, Boolean schemaReqTypeAttr, XmlSerializerNamespaces serializeNs)
   at System.Web.Services.Protocols.SoapMessageFormatter.execute(String targetNamespace)
   at System.Web.Services.Protocols.SoapMessageSerializer.Serialize(XmlWriter writer, SoapHttpClientProtocol client, Object[] parameters, LogicalSoapMethod soapMethod, Boolean soap12)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

谷歌没有提出任何有用的东西,而且我处于死胡同,所以欢迎提出建议。到目前为止,我唯一的想法是它存在某种不匹配,因为CF使用不同版本的System.dll来处理Web服务项目。

1 个答案:

答案 0 :(得分:0)

这是因为我使用了Web引用的子类,并且还使用了一个接口,即:

public class MyWebServiceReference : RawWebServiceReference, IService {}

该接口位于RawWebServiceReference和MyWebServiceReference的单独项目中,其中一些方面导致错误。