Question

Ok, this is driving me insane. I've been trying to build service implementation code from a predefined wsdl and it is consistently returning a message on the service contract/interface:

// 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've tried to do this using svcutil.exe and WSCF's Generate Service code wizard, and both return the same result.

Below is the WSDL I'm using. I've added the types in here, I do have them broken out into a seperate xsd, just didn't want to post both. Using this wsdl(with all types embedded) also generates the same problems.

I've reviewed this blog post(http://pzf.fremantle.org/2007/05/handlign.html), it's about all I could find regarding this problem. I think I've done everything it says to do, but am still having issues.

Has anyone else come across this? It's very infuriating, maybe I'm missing something obvious. Any help will 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 seemed to work. It was just a missing 's' in the response type. DOH!

Now the service code seems to be generating fine, but when I browse to my service there is no data contract/xsd's and there are no operations on the wsdl.

It just looks like:

<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 would expect it to look like the wsdl I generated the code from, no?

No correct solution

OTHER TIPS

Try this - your request and response messages in WSDL should be

  • the same name as your operation for the request ("GetMetrics")
  • the name of the operation + "Response" for your response ("GetMetricsResponse")

So try changing your 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 that help at all?

If not: try updating your actual <xs:element> in your XSD to match the same pattern - the request type must be the same as the operation you're calling, the response object must be (MethodName)Response .

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top