Создание кода из WSDL в WCF продолжает возвращать сообщение не соответствует значению по умолчанию
-
24-09-2019 - |
Вопрос
Хорошо, это сводит меня с ума. Я пытался создать код реализации услуг из предопределенного WSDL, и он последовательно возвращает сообщение о контракте / интерфейсе обслуживания:
// CODEGEN: Generating message contract since the wrapper name (GetMetricsRequest) of message GetMetricsRequest does not match the default value (GetMetrics)
[System.ServiceModel.OperationContractAttribute(Action="GetMetrics", ReplyAction="*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
GetMetricsResponse GetMetrics(GetMetricsRequest request);
Я пытался сделать это, используя SVCUTIL.EXE и WSCH Generate Wizard сервисного кода, и оба возвращают один и тот же результат.
Ниже приведен WSDL, который я использую. Я добавил здесь типы, у меня есть их разбитые в отдельный XSD, просто не хотелось публиковать оба. Используя этот WSDL (со всеми типами встроенным) также генерирует те же проблемы.
Я рассмотрел этот пост блога (http://pzf.fremantle.org/2007/05/handlign.html.), речь идет обо всем, что я мог найти относительно этой проблемы. Я думаю, что сделал все, что он говорит, но у меня все еще есть проблемы.
Кто-нибудь еще встречается с этим? Это очень беседует, может быть, я скучаю с чем-то очевидным. Любая помощь будет оценена.
<wsdl:definitions
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:MyNameSpace:V1_0"
targetNamespace="urn:MyNameSpace:V1_0">
<wsdl:types>
<xs:schema targetNamespace="urn:MyNameSpace:V1_0">
<xs:element name="GetMetricsRequest">
<xs:complexType>
<xs:sequence>
<xs:element nillable="true" name="GetMetricRequestElement" type="tns:GetMetricRequestType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetMetricResponse">
<xs:complexType>
<xs:sequence>
<xs:element nillable="true" maxOccurs="unbounded" name="GetMetricResponseElement" type="tns:GetMetricResponseType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="GetMetricResponseType">
<xs:sequence>
<xs:element nillable="true" name="Metrics" type="tns:MetricsType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="GetMetricRequestType">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="MetricCriteria" nillable="true" type="tns:MetricCriteriaType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="AvailableMetricType">
<xs:restriction base="xs:string">
<xs:enumeration value="MetricType1"/>
<xs:enumeration value="MetricType2"/>
<xs:enumeration value="MetricType3"/>
<xs:enumeration value="MetricType4"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="AvailableMetricsType">
<xs:sequence>
<xs:element minOccurs="1" nillable="true" maxOccurs="unbounded" name="MetricType" type="tns:AvailableMetricType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="MetricDimensionType">
<xs:restriction base="xs:string">
<xs:enumeration value="Store"/>
<xs:enumeration value="Workgroup"/>
<xs:enumeration value="BusinessDate"/>
<xs:enumeration value="JobClass"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="MetricDimensionsType">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" nillable="true" name="MetricDimension" type="tns:MetricDimensionType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MetricCriteriaType">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="storeNumber" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="workgroup" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="jobClass" nillable="true" type="xs:string"/>
<xs:element maxOccurs="1" nillable="true" name="dateStart" type="xs:dateTime"/>
<xs:element maxOccurs="1" nillable="true" name="dateEnd" type="xs:dateTime"/>
<xs:element maxOccurs="1" name="dimensions" nillable="true" type="tns:MetricDimensionsType"/>
<xs:element maxOccurs="1" name="metricTypes" nillable="true" type="tns:AvailableMetricsType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MetricType">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="businessDate" nillable="true" type="xs:dateTime"/>
<xs:element minOccurs="0" maxOccurs="1" name="store" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="workgroup" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="jobClass" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="metricValue" nillable="true" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MetricsType">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Metric" nillable="true" type="tns:MetricType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="GetMetricsRequestMessage">
<wsdl:part name="parameters" element="tns:GetMetricsRequest"/>
</wsdl:message>
<wsdl:message name="GetMetricsResponseMessage">
<wsdl:part name="parameters" element="tns:GetMetricResponse"/>
</wsdl:message>
<wsdl:portType name="Metric">
<wsdl:operation name="GetMetrics">
<wsdl:input message="tns:GetMetricsRequestMessage"/>
<wsdl:output message="tns:GetMetricsResponseMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MetricService" type="tns:Metric">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="GetMetrics">
<soap:operation soapAction="GetMetrics" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Metric">
<wsdl:port name="GetMetrics" binding="tns:MetricService">
<soap:address location="http://myurl/myproj/1.0/MyService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Спасибо marc_s,
Хорошо, это, казалось, работал. Это было просто отсутствующее в типе ответа. Дох!
Теперь код обслуживания, похоже, генерирует нормально, но когда я просматриваю своему сервису, нет контракта данных / XSD, и на WSDL нет операций.
Это просто выглядит как:
<wsdl:definitions name="MetricServiceImplementation" targetNamespace="http://tempuri.org/">
<wsdl:import namespace="urn:GiantEagle:Services:Systems::Metric:V1_0" location="http://localhost:2814/Services/MetricService.svc?wsdl=wsdl0"/>
<wsdl:types/>
<wsdl:binding name="BasicHttpBinding_MetricService" type="i0:MetricService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
</wsdl:binding>
<wsdl:service name="MetricServiceImplementation">
<wsdl:port name="BasicHttpBinding_MetricService" binding="tns:BasicHttpBinding_MetricService">
<soap:address location="http://localhost:2814/Services/MetricService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Я ожидал, что это выглядит как WSDL, я создал код от, нет?
Нет правильного решения
Другие советы
Попробуйте это - ваши сообщения запроса и ответа в WSDL должны быть
- То же самое имя, что и ваша операция по запросу («GetMetrics»)
- Название операции + «ответ» для вашего ответа («GetMetricsResponse»)
Так что попробуйте изменить свой WSDL на:
<wsdl:message name="GetMetrics">
<wsdl:part name="parameters" element="tns:GetMetricsRequest"/>
</wsdl:message>
<wsdl:message name="GetMetricsResponse">
<wsdl:part name="parameters" element="tns:GetMetricResponse"/>
</wsdl:message>
А также обновить ваш портеттп:
<wsdl:portType name="Metric">
<wsdl:operation name="GetMetrics">
<wsdl:input message="tns:GetMetrics"/>
<wsdl:output message="tns:GetMetricsResponse"/>
</wsdl:operation>
</wsdl:portType>
Это помогает вообще?
Если нет: попробуйте обновить свой актуальный <xs:element>
В вашем XSD, чтобы соответствовать тому же шаблону - тип запроса должен совпадать с операцией, которую вы вызываете, объект ответа должен быть (метод знамения).
Удалить "*"
в ReplyAction("*")
принадлежащий OperationContract