Auto generate service via Microsoft WCF Web Service Reference Provider in VS 2019

Do you want to create a native client or integrate with third party applications: webservices are the solution.

Moderator: car031

crovaxon
Posts: 2
Joined: Tue Nov 19, 2019 11:12 am

Auto generate service via Microsoft WCF Web Service Reference Provider in VS 2019

Fri Dec 06, 2019 5:50 pm

Hello everyone,

I am working on a little project using C# ASP Dotnet Core 3 and I wanted to include LogicalDoc in this by trying to automatically generate the reference service files using the wsdl that a running LogicalDoc instance provides. For this I was using the Microsoft WCF Web Service Reference Provider in Visual Studio 2019 to save me all the work in setting up the service for the SOAP calls.
I generated (so far) service references for Auth, Security, Folder and Document and have been slowly creating methods for myself to interact with the SOAP Api, user creation and authentication basic interaction with folders are working for me already.
I got now into working with Documents and I am running into a problem I can't figure out.

I am now trying to implement file uploading and wanted to use the upload SOAP call for this. There I noticed in my generated code that the upload method was not created in a way to tread DocID and FolderID as optional as it is defined in the SOAP API Documentation for LogicalDoc CE 8.3.2. This is a problem when I want to upload a new file of course, it having no Document ID yet.

Code: Select all

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.1")]
    [System.ServiceModel.MessageContractAttribute(WrapperName="upload", WrapperNamespace="http://ws.logicaldoc.com", IsWrapped=true)]
    public partial class upload
    {
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://ws.logicaldoc.com", Order=0)]
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string sid;
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://ws.logicaldoc.com", Order=1)]
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public long docId;
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://ws.logicaldoc.com", Order=2)]
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public long folderId;
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://ws.logicaldoc.com", Order=3)]
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public bool release;
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://ws.logicaldoc.com", Order=4)]
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string filename;
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://ws.logicaldoc.com", Order=5)]
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string language;
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://ws.logicaldoc.com", Order=6)]
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType="base64Binary")]
        public byte[] content;
        
        public upload()
        {
        }
        
        public upload(string sid, long docId, long folderId, bool release, string filename, string language, byte[] content)
        {
            this.sid = sid;
            this.docId = docId;
            this.folderId = folderId;
            this.release = release;
            this.filename = filename;
            this.language = language;
            this.content = content;
        }
...
I figured that the auto generation must have not worked properly. As far as I have understood handling of optional values in a SOAP Api, there should have been additional boolean methods generated, namely docIdSpecified and folderIdSpecified, where I can specify if a value has been set, but those are missing.
It is as if the second wsdl file which is imported inside the document.wsdl, where MinOccurs = 0 are set for the optional values in upload, are not being respected at all.

I looked into generating the service file again but doing it my self this time, using the dotnet-scvutil executable directly and I noticed that when I set the tool to "not unwrap "parameters" member of document-wrapped-literal messages", both wsdl files get to be processed. This results in every call being there twice, the second one has a 1 appended to its name. and they look somewhat different from each other, but in this case, the elements with a MinOccurs of 0 are getting their proper *Specified methods. Still, this generated code is very hard to read and use with everything being there twice so it does not seem to be the proper way.

Has anyone with experience in using WCF an Idea on how to fix this or a tip on how to approach generating the service? Fixing it manually is only useful till the next time the code would be regenerated.
Please keep in mind I am writing my code in C# ASP Dotnet Core 3.

I am grateful for any help.

Return to “Web Services”

Who is online

Users browsing this forum: No registered users and 4 guests