MonoTouch, Sharepoint web services and xs:any

2020-07-22 17:19发布

问题:

Has ANYONE gotten a web service call to work with SharePoint to operate with MonoTouch/MonoDevelop/Mono??

I am able to get the WSDL from the typical endpoint (/_vti_bin/Lists.asmx in this case), and MonoDevelop creates a Reference.cs as expected.

I have modified the Reference.cs to include the "name" parameter, so all XmyAnyElements now look like: [System.Xml.Serialization.XmlAnyElement("Any","")] //name and namespace

While this can compile, runtime complains about the XmlNode. Fair enough, I made it into XmlNode[] so it could be an array, which invoke[] seems to want.

I then build a GetListItemsQuery and pass it along to my GetListItems call via: var result = svc.GetListItems ("Tasks", null, q, null, "100", null, null);

While I can connect and get the web service to respond, all responses are coming back with null in the Any field.

回答1:

What I have found that works is quite frustrating, but successful.

Pull up Visual Studio on a Windows machine, start an old-school .Net 2.0 windows form app, and connect to the same WSDL. This will create a new Reference.cs file. Bring that file into your MonoTouch app.

Modify the constructor to use the OLD MonoTouch constr, as the .Net 2.0 one will not compile.

Imported constructor

/// <remarks/>
    public Lists() {
        *this.Url = global::test.Properties.Settings.Default.test_gxgvwn1_Lists; //BREAKS HERE, BY THAT'S OK!*
        if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
            this.UseDefaultCredentials = true;
            this.useDefaultCredentialsSetExplicitly = false;
        }
        else {
            this.useDefaultCredentialsSetExplicitly = true;
        }
    }

MonoTouch generated (I used this):

    public Lists() {
        this.Url = "http://www.mysite.com/_vti_bin/Lists.asmx";
    }

    public Lists(string url) {
        this.Url = url;
    }

Once that is changed, the app will compile and the result = svc.GetListItems() will actually return data in the XmlNodes!