Generating code from WSDL to WCF saves the returned message does not match the default value

Okay, this is driving me crazy. I tried to create the service implementation code from the predefined wsdl, and it constantly returns a service contract / interface message:

// 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); 

I tried to do this using svcutil.exe and the WSCF Generate Service code wizard, and both return the same result.

Below is the WSDL. I added types here, I broke them into a separate xsd, I just did not want to publish both. Using this wsdl (with all built-in types) also poses the same problems.

I looked at this blog post ( http://pzf.fremantle.org/2007/05/handlign.html ), this is about everything I could find on this issue. I think he did everything he said, but I still have problems.

Has anyone else come across this? This is very annoying, maybe I'm missing something obvious. Any help would be greatly appreciated.

 <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> 

Thanks marc_s,

Ok, that worked. It was just the missing 's' in the response type. Doh!

Now the service code seems to be generated normally, but when I look at my service, there is no data contract / xsd and no operations with wsdl.

It looks simple:

 <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> 

I expect it to look like wsdl, from which I generated the code, no?

+7
c # wsdl wcf
source share
2 answers

Try this - your requests and response messages in the WSDL should be

  • same name as your operation for the query ("GetMetrics")
  • operation name + "Response" for your answer ("GetMetricsResponse")

So try changing the WSDL to:

 <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> 

and also update your portType:

 <wsdl:portType name="Metric"> <wsdl:operation name="GetMetrics"> <wsdl:input message="tns:GetMetrics"/> <wsdl:output message="tns:GetMetricsResponse"/> </wsdl:operation> </wsdl:portType> 

Does it help at all?

If not: try updating the actual <xs:element> in the XSD according to the same pattern - the type of request should be the same as the operation you are calling, the response object should be (MethodName) Response.

+5
source share

Remove "*" in ReplyAction("*") OperationContract

+3
source share

All Articles