locked
Method can not be reflected RRS feed

All replies

  • Please post the full exception, including any inner exceptions. Also, please try to create a small example that reproduces the problem. You can probably make a copy of the WSDL and remove all but two operations that use the same output message. Then post the small WSDL that has the problem.

     

    Wednesday, January 16, 2008 12:07 PM
    Moderator
  • Thanks for the quick response.

     

    The error is:

     

     

    Method SimpleService.EchoComplex1 can not be reflected.
    
    

     

    The inner exception is:

     

     

    The XML element 'CommonRequest' from namespace 'http://tempuri.org/' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute.
    
    

     

     

    Note that the suggested solutions in the message are not applicable as they will change the soap.

     

    The stack trace is:

      at System.Xml.Serialization.XmlReflectionImporter.ReconcileAccessor(Accessor accessor, NameTable accessors)\r\n  at System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access)\r\n  at System.Web.Services.Protocols.SoapReflector.ImportMembersMapping(XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, Boolean serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault, XmlReflectionMember[] members, Boolean validate, Boolean openModel, String key, Boolean writeAccess)\r\n  at System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs)
    
    

     

     

     

     

    The relevant proxy code is:

     

    [SoapDocumentMethodAttribute(...ResponseElementName="CommonResponse"...)]
    public MyClass EchoComplex(MyClass someClass) {...}
    
    ...
    
    [SoapDocumentMethodAttribute(...ResponseElementName="CommonResponse"...)]
    public MyClass EchoComplex1(MyClass someClass) {...}
    
    
    

     

    And a sample wsdl is:

     

     

    <?xml version="1.0" encoding="utf-8"?>
    <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
     <wsdl:types>
      <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">  
       <s:element name="CommonRequest">
        <s:complexType>
         <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="someClass" type="tns:MyClass" />
         </s:sequence>
        </s:complexType>
       </s:element>
       <s:complexType name="MyClass">
        <s:sequence>
         <s:element minOccurs="1" maxOccurs="1" name="i" type="s:int" />
         <s:element minOccurs="0" maxOccurs="1" name="s" type="s:string" />
        </s:sequence>
       </s:complexType>
       <s:element name="CommonResponse">
        <s:complexType>
         <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="MyResult" type="tns:MyClass" />
         </s:sequence>
        </s:complexType>
       </s:element>   
      </s:schema>
     </wsdl:types>
     <wsdl:message name="EchoComplexSoapIn">
      <wsdl:part name="parameters" element="tns:CommonRequest" />
     </wsdl:message>
     <wsdl:message name="EchoComplexSoapOut">
      <wsdl:part name="parameters" element="tns:CommonResponse" />
     </wsdl:message>
     <wsdl:message name="EchoComplex1SoapIn">
      <wsdl:part name="parameters" element="tns:CommonRequest" />
     </wsdl:message>
     <wsdl:message name="EchoComplex1SoapOut">
      <wsdl:part name="parameters" element="tns:CommonResponse" />
     </wsdl:message>
     <wsdl:portType name="SimpleServiceSoap">
      <wsdl:operation name="EchoComplex">
       <wsdl:input message="tns:EchoComplexSoapIn" />
       <wsdl:output message="tns:EchoComplexSoapOut" />
      </wsdl:operation>
      <wsdl:operation name="EchoComplex1">
       <wsdl:input message="tns:EchoComplex1SoapIn" />
       <wsdl:output message="tns:EchoComplex1SoapOut" />
      </wsdl:operation>
     </wsdl:portType>
     <wsdl:binding name="SimpleServiceSoap" type="tns:SimpleServiceSoap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
      <wsdl:operation name="EchoComplex">
       <soap:operation soapAction="http://tempuri.org/EchoComplex" style="document" />
       <wsdl:input>
        <soap:body use="literal" />
       </wsdl:input>
       <wsdl:output>
        <soap:body use="literal" />
       </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="EchoComplex1">
       <soap:operation soapAction="http://tempuri.org/EchoComplex1" 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="SimpleService">
      <wsdl:port name="SimpleServiceSoap" binding="tns:SimpleServiceSoap">
       <soap:address location="http://localhost:3919/MyWebServices/Services/SimpleService.asmx" />
      </wsdl:port>
     
     </wsdl:service>
    </wsdl:definitions>
    
    

     

    Thanks, 

    Yaron

     


    Wednesday, January 16, 2008 1:12 PM
  • Yes, you do have duplicate signatures. From WSDL.EXE:

     


    C:\Documents and Settings\JSaunders\My Documents\MVP\Answers\Web Services>wsdl yaron.wsdl
    Microsoft (R) Web Services Description Language Utility
    [Microsoft (R) .NET Framework, Version 2.0.50727.1432]
    Copyright (C) Microsoft Corporation. All rights reserved.
    Warning: This web reference does not conform to WS-I Basic Profile v1.1.
    R2710: The operations in a wsdl:binding in a DESCRIPTION MUST result in wire signatures that are different fro
    m one another. An endpoint that supports multiple operations must unambiguously identify the operation being i
    nvoked based on the input message that it receives. This is only possible if all the operations specified in t
    he wsdl:binding associated with an endpoint have a unique wire signature.
      -  Input message 'EchoComplexSoapIn' from namespace 'http://tempuri.org/' has wire signature 'http://tempuri
    .org/:CommonRequest'.
      -  Input message 'EchoComplex1SoapIn' from namespace 'http://tempuri.org/' has wire signature 'http://tempur
    i.org/:CommonRequest'.

    For more details on the WS-I Basic Profile v1.1, see the specification
    at
    http://www.ws-i.org/Profiles/BasicProfile-1.1.html.

     

    You need to use two different element names for the requests. For instance, see the following excerpt:

     

    Code Block

      <wsdl:types>

        <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">    

          <s:element name="CommonRequest1" type="tns:CommonRequestType"/>

          <s:element name="CommonRequest2" type="tns:CommonRequestType"/>

          <s:complexType name="CommonRequestType">

                <s:sequence>

                      <s:element minOccurs="0" maxOccurs="1" name="someClass"

                            type="tns:MyClass">

                      </s:element>

                </s:sequence>

          </s:complexType>

        </s:schema>

      </wsdl:types>

      <wsdl:message name="EchoComplexSoapIn">

        <wsdl:part name="parameters" element="tns:CommonRequest1" />

      </wsdl:message>

      <wsdl:message name="EchoComplex1SoapIn">

        <wsdl:part name="parameters" element="tns:CommonRequest2" />

      </wsdl:message>

     

     

     

    Wednesday, January 16, 2008 5:24 PM
    Moderator
  • Thanks

     

    The warning in wsdl.exe is a WS-I compliance warning but this does not mean that the wsdl is illegal. Most wsdls in the world are probably violating WS-I in this way or the other. There is no principle problem with duplicated signatures as the soapAction is always specified in the HTTP header or wsa. These warnings do not fail proxy creation as the error is just at run time and looks like a framework bug.

     

    I was able to workaround this by changing the parts named "parameters" in the wsdl to "myParams". This caused wsdl.exe to create a doc/lit/bare proxy instead of doc/lit/wrapped and I was able to work with it (it created the expected soap). How robust do you think this is? I think this proves that the error is a framework bug in wrapped style since in the bare style I don't get any errors.

     

    Thanks,

    Yaron

    Wednesday, January 16, 2008 6:02 PM
  • Ok, exactly where did you see the error message? While running WSDL.EXE? If so, what version were you using. Please post the entire output from WSDL.EXE if that's what you were using.

     

    Wednesday, January 16, 2008 6:09 PM
    Moderator
  • The error is not in wsdl.exe. Actually it creates the proxy w/o any errors. The error is at run-time in the moment I instantiate the proxy, e.g. Proxy myProxy=new Proxy(). I specified the full error message in a previous post. This is in .net 2.0 and reproducable 100% I'm sure you will get the same error with just this one line of code.

     

    Thanks

     

    Wednesday, January 16, 2008 6:23 PM
  • Thanks. I've reproduced the problem. I'll have to get back to you on a solution. In the meantime, you may want to look at http://search.live.com/results.aspx?q=%22references+a+method+and+a+type%22&form=QBRE.
    Wednesday, January 16, 2008 6:47 PM
    Moderator
  • Hi,

    I am eagerly waiting for the solution to this problem, as I am too encounter similar problem.  Unlike
    yaronn01 I am also writing the service side of the program (FYI, I am using gSoap toolkit on the server and c# on client).  I notice the problem only occur when I try to return same structure with same name.  I am able to solve the problem by redefining the structure to different name but this will make the code very messy. For example,  I have a structure called CommonResponse I'll need to redefine the structure to CommonResponse2 with same contents.  If I have 10 functions all return CommonResponse I'll get 10 difference structure. 

    I don't know if this is obvious information since I am new to SOAP.  I hope this help you find the solution quicker

     


    Wednesday, January 16, 2008 10:24 PM
  • I'm afraid I still haven't had time to get into this in detail (I expect it will be my lunch hour activity), but have you tried what I suggested? Create elements with different names but with the same type? Does that help at all on the server side?

     

    Thursday, January 17, 2008 11:15 AM
    Moderator
  • We just ran into this problem and we are not sure what the resolution is.  Everything looks fine in code, except one potential issue.  One of the operations is returning a class that contains types defined in another project/dll.

    Tuesday, February 5, 2008 12:56 PM
  • Exitboy: Thanks for reminding me that I haven't resolved this for Yaron. However, please be certain that you have exactly the same problem, including the InnerException and the output from wsdl.exe. Otherwise, when I finally get around to looking at this, if I find a solution, it may not be the solution for your problem.

     

    Yaron: sorry about that. I've got to come up with a better mechanism to remind me to deal with issues from these forums. Unfortunately, this is going to be a very busy week, and I may not be able to get to it until Saturday.

     

    Please feel free to kick me about it if I don't get back to you.

    Tuesday, February 5, 2008 2:56 PM
    Moderator
  • Hi John Saunders,

    Sadly, I also bumped into this on a big project, while defining a replacement webproject from a website project (C:\..\etc) in Visual Studio and setting it as my startup project, and it seems this is the only place with recent activity.
    In short, the webservice implements an interface and it is in another assembly. It uses a return type defined in another class and subnamespace (but in the same assembly as the interface).

    I got it to work by putting the following in front of the returned class type
        [Serializable]
        [XmlRoot(Namespace = "http://mynamespace.nl/SERVICE/different", ElementName="SetupResponse")]
        [XmlType(Namespace="http://mynamespace.nl/SERVICE/different", IncludeInSchema = true)]
    public class SetupResponse
    {
    /// some stuff
    }

    But the thing is the Namespace may NOT be the same as the namespace defined in the web service:
    [WebService(Namespace="http://mynamespace.nl/SERVICE", Name = "Some Service")]

    And that is a real shame. I have some compatibility issues because the xml now has a different namespace for the return type and my clients don't expect that and it is hard to upgrade them (other companies use them). And of course it has to be done and working on monday Sad


    So I hope this will point you to something and a fix/workaround is just a lunch break away Smile

    Kind regards,

    Wilfred Dittmer
    Friday, February 8, 2008 3:44 PM
  • Hi,

    Okay, did some more poking. It does not like the SetupResponse class because there is already a SetupResponse in the namespace. It generates its own SetupResponse from the Setup webmethod.
    Okay this a difference between a website project and web project then. In the websiteproject I control the return type name as it ends up in the XML/SOAP, and with the web project it generates <MethodName>Response and <MethodName>Result and discards the return type name.

    WebSite:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlnsTongue Tiedoap="http://schemas.xmlsoap.org/soap/envelope/">
     <soap:Body>
    <SetupResponse xmlns="http://xxx/xx">
    <SetupResponse>
    <ResponseStatus>int</ResponseStatus>
     </SetupResponse>
    </SetupResponse>
     </soap:Body>
     </soap:Envelope>

    WebProject (renamed Setup webmethod to Setup2 to make it work):
    <?xml version="1.0" encoding="utf-8"?>
     <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlnsTongue Tiedoap="http://schemas.xmlsoap.org/soap/envelope/">
     <soap:Body>
    <Setup2Response xmlns="http://eventis.nl/TRAXIS/VODServerToTRAXIS">
    <Setup2Result>
    <ResponseStatus>int</ResponseStatus>
     </Setup2Result>
    </Setup2Response> </soap:Body> </soap:Envelope>

    Hmm. Tricky

    Regards,
    Wilfred





    Friday, February 8, 2008 4:27 PM
  •  

    Hi John - any news for me?

     

    Yaron

    Thursday, February 14, 2008 11:57 PM
  • Hi everybody.. Any news on this??, I have same problem. wsdl reports 2 warning about duplicates , like this thread example and runtime show a mehtod can not be reflected.

    any ideas?
    rub
    Wednesday, June 25, 2008 7:29 PM
  • I get exactly the same runtime error.  In exactly the same place.  Using .Net 2.0 with WSE 3.0.  Isn't there any news on this?  We have 2000 webservice calls in our application.  About 200 different WSDL and proxy class files.  Do I really have to try all the messy solutions like: Change SetupResponse to Setup2Resonse, Setup3Response, Setup4Response??
    Phreud
    Tuesday, March 31, 2009 10:23 PM
  • I am in the same boat with a few message contract resposes reused for multiple operation contracts. I do not really want to create a unique response for each op contract. I can not seem to find an answer to this. Does any one have any updates?

    XidiX
    Tuesday, May 12, 2009 2:07 PM
  • I am in the same boat with a few message contract resposes reused for multiple operation contracts now.  Does any one have any update?

    I want to test is it OK if I use .net3.0

    If you have any soulutions please share them~ Thanks

     

    Rongkui

    Monday, August 16, 2010 5:28 AM
  • If you are using message contracts, then you are using WCF, so you do not have the same problem.

    You are also posting in the wrong forum. Please start a new thread in the WCF Forum .


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Monday, August 16, 2010 7:11 PM
    Moderator
  • Please publish the wsdl here.
    http://webservices20.blogspot.com/
    WCF Security, Performance And Testing Blog
    Tuesday, August 17, 2010 10:36 AM
  • Hi Yaron,

    Sorry for digging out an old post. I don't know where else to turn to.

    It seems you were able to make this work by changing the name "parameters" to "myParams" which created a bare proxy. However, when I try this, I still get the "Method cannot be reflected" error. Can you please provide the exact changes that you made in order for this to work ?

     

    Thanks,

    Kunal

    Monday, May 9, 2011 10:19 PM
  • Hi,

     

    I am dealing with the same problem for ages. I need to use the wsdl (http://dgpys.teias.gov.tr/dgpys/services/EVDServis?wsdl) in my WinForms (.Net 4.0) application. I got the same proxy error in runtime when I try to create teh object as var evd = new EVDServis(). wsdl.exe creates the EVDServis.cs just fine but result is the same.

     

    Is there any chance that I cannot use it with .net framework because I heard from couple of friends that they can use the wsdl without any problems in java.

    Exception: {"Method EVDServis.getSistemDengesizlikFiyat can not be reflected."}

    InnerException: {"The XML element 'EnergyAccountReport' from namespace 'http://ws.dgpys.deloitte.com' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute."}

    Regards,

    Mert Ece

    ----------------------------------------------------

     

    replaced all parameters to myParams in wsdl before creating the proxy and woila... although I came across another problem, at least I am one step ahead now.

    thanks

    • Edited by mert.ece Tuesday, September 27, 2011 4:12 PM
    • Proposed as answer by damla.yilmazer Tuesday, December 4, 2012 11:35 AM
    • Unproposed as answer by damla.yilmazer Tuesday, December 4, 2012 11:35 AM
    Tuesday, September 27, 2011 3:34 PM
  • Unless you're using .NET 2.0, you should try this with WCF ("Add Service Reference"). If there's a problem, then try using the svcutil.exe program. Since it's a Console application, it can display any error messages directly.

     


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Thursday, September 29, 2011 3:09 AM
    Moderator
  • I ve had the same problem when I was exposing more than one method with the same input and output parameters.

    The cause of issue in the above WSDL is highlighted below-

    <wsdl:message name="EchoComplexSoapIn">
      <wsdl:part name="parameters" element="tns:CommonRequest" />
    </wsdl:message>
    <wsdl:message name="EchoComplexSoapOut">
      <wsdl:part name="parameters" element="tns:CommonResponse" />
    </wsdl:message>
    <wsdl:message name="EchoComplex1SoapIn">
      <wsdl:part name="parameters" element="tns:CommonRequest" />
    </wsdl:message>
    <wsdl:message name="EchoComplex1SoapOut">
      <wsdl:part name="parameters" element="tns:CommonResponse" />
    </wsdl:message>

    Now in our project we do use WSDL exporter (IWsdlExportExtension) for a different reason though. So I renamed the above in the exporter to make them unique and that resolved the issue.

    P.S. There must be a better way to resolve this using some attributes i.e. without using IWsdlExportExtension.


    MCTS BTS 2006
    Monday, January 30, 2012 2:15 PM
  • the attached link is  not working it shows 404 error.
    Monday, February 6, 2012 7:10 AM
  • Can you please paste the proper error as provided link is having 404 error.
    Tuesday, February 7, 2012 10:25 AM
  • Hi,

    Did you find solution? I have trouble with this EVDServis wsdl. Could you share your experience for this topic?

    Tuesday, December 4, 2012 9:56 AM