Как создать веб-сервис из файлов XSD и WSDL? - PullRequest
1 голос
/ 11 июня 2019

Вот проблема: у меня есть файл .WSDL и файл .XSD, и мне нужно создать веб-сервис для включения в решение.Первое, что я сделал, это создал новый проект => WCF => Приложение-служба WCF. После этого я знаю, что мне нужны классы для создания веб-сервиса вокруг него, поэтому я попробовал разные вещи, чтобы сгенерировать их из файлов WSDL и XSD, но этоне работал.

Я пробовал несколько способов:

1: xsd /c myFile.xsd /n:mynamespace

Но выдал мне несколько ошибок:

Schema validation warning: The type attribute cannot be present with either simpleType or complexType.

 <xsd:complexType name="R000000">
                <xsd:annotation>
                    <xsd:documentation xml:lang="EN">Cabeçalho</xsd:documentation>
                </xsd:annotation>
                <xsd:sequence>
                    <xsd:element name="R00000100" type="datehourminsec">
                        <xsd:annotation>
                            <xsd:documentation>Data / Hora</xsd:documentation>
                        </xsd:annotation>
                        <xsd:simpleType>
                            <xsd:restriction base="xsd:string">
                                <xsd:length value="14"/>
                            </xsd:restriction>
                        </xsd:simpleType>
                    </xsd:element>
                    <xsd:element name="R00000110" type="version">
                        <xsd:annotation>
                            <xsd:documentation>Versão</xsd:documentation>
                        </xsd:annotation>
                </xsd:sequence>
            </xsd:complexType>

2: svcutil.exe /language:C# /out:myService.cs /n:*,mynamespace myFile.wsdl

Если я пытаюсь использовать этот метод, это также выдает мне много ошибок,

Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: The type attribute cannot be present with either simpleType or complexType.
XPath to Error Source: //wsdl:definitions[@targetNamespace='myurl.pt/myservice/service']/wsdl:portType[@name='ELServiceSoap']


Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='myurl.pt/myservice/service']/wsdl:portType[@name='ELServiceSoap']
XPath to Error Source: //wsdl:definitions[@targetNamespace='myurl.pt/myservice/service']/wsdl:binding[@name='ELServiceSoap']


Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='myurl.pt/myservice/service']/wsdl:binding[@name='ELServiceSoap']
XPath to Error Source: //wsdl:definitions[@targetNamespace='myurl.pt/myservice/service']/wsdl:service[@name='ELService']/wsdl:port[@name='ELServiceSoap']


Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.

Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.

И даже если я используюкоманда с параметром / dataContractOnly, это возвращает к ошибке, которая была у меня в команде xsd:

Error: An error occurred in the tool.

Error: The type attribute cannot be present with either simpleType or complexType.

Я не уверен, что я иду в правильном направлении для создания веб-службы,но если я, как я могу решить эту ошибку?

...