简体   繁体   English

从CompactFramework Client消耗WebService

[英]Consuming WebService From CompactFramework Client

I'm trying to call a webservice method like this: 我试图调用这样的webservice方法:

myService.Register("mystring");

The webmethod definition is just: webmethod的定义只是:

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

But I receive the following System.InvalidOperationException: 但是我收到以下System.InvalidOperationException:

"The type System.String was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically." “不希望使用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)

Google isn't turning up anything useful and I'm at a dead-end so suggestions would be welcome. Google并未提供任何有用的工具,而且我处于死胡同,因此欢迎提出建议。 My only thought so far is that it's some kind of mismatch because CF uses a different version of the System.dll to the webservice project. 到目前为止,我唯一的想法就是这有点不匹配,因为CF对Webservice项目使用了不同版本的System.dll。

This was caused by the fact I was using a subclass of the web reference, and also using an interface, ie: 这是由于我使用了Web参考的子类,并且还使用了一个接口,即:

public class MyWebServiceReference : RawWebServiceReference, IService {}

The interface was in a separate project to the RawWebServiceReference and MyWebServiceReference, and some aspect of this was causing the error. 该接口位于RawWebServiceReference和MyWebServiceReference的单独项目中,并且某些方面引起了错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM