none
WCF envelope method prefix problem RRS feed

  • Question

  • Hi all,

    WCF service is called from diferent clients and with diferent envelope structures.

    Sample is made for simple function Ping:

    Interface:

    [OperationContract] 
    string Ping(string value);

    Implementation:

    public string Ping(string value)
    {
        return "Value received:" + value;
    }

    How can I configure OperationContract AND/OR Service contract to work with both envelopes, first with method name 

    Ping and second with m prefix in method name ( in second case method is invoked, do to SOAPAction in header, but with null parameters ).

    Please, HELP !

    Best regards, Robert

    Envelope samples ( with first works ok, second not):

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Body>
        <Ping xmlns="http://tempuri.org/">
          <value>xxPINGxx</value>
        </Ping>
      </s:Body>
    </s:Envelope>
    
    <env:Envelope 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <env:Body>
        <m:Ping xmlns:m="http://tempuri.org/">
          <value xsi:type="xs:string">xxPINGxx</value>
        </m:Ping>
      </env:Body>
    </env:Envelope>


    Friday, October 4, 2013 11:57 AM

Answers

  • Hi,

    The Ping is in the default namespace so there is no prefix, but the elements inside do have it.

    xmlns:m=http://tempuri.org/

    so the prefix for this namespace is m. (because of 'm=') and it is different from the default namespace.

    In the ServiceContractAttribute of your method

    string Ping(string value);

    You can write the following:

    [ServiceContract(Namespace=http://tempuri.org/)]

    But you cannot have this:

    <m:Ping xmlns:m="http://tempuri.org/">

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, October 7, 2013 9:19 AM
    Moderator

All replies

  • Hi,

    The Ping is in the default namespace so there is no prefix, but the elements inside do have it.

    xmlns:m=http://tempuri.org/

    so the prefix for this namespace is m. (because of 'm=') and it is different from the default namespace.

    In the ServiceContractAttribute of your method

    string Ping(string value);

    You can write the following:

    [ServiceContract(Namespace=http://tempuri.org/)]

    But you cannot have this:

    <m:Ping xmlns:m="http://tempuri.org/">

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, October 7, 2013 9:19 AM
    Moderator
  • Tnx for answer, I was expected that kind.

    My problem is, than many different clients call our service. One of our customers uses

    some strange third party component. When envelope is formed with than one, they say, they can't 

    avoid component to add prefix, like in sample. I was just wondering, if there is a solution to solve problem on our site, with some namespace "overload" or something similar. 

    I see, that it is better, that our customer contact third party component author and ask him to behave more 

    seriously.

    Best regards,

    Robert


    • Edited by robasoft Tuesday, October 8, 2013 10:40 AM
    Tuesday, October 8, 2013 10:22 AM
  • Hi,

    Since The Ping is in the default namespace so there is no prefix, it will be difficult to do as said in your sampple.

    So you have to let our customer contact third party component author and ask him to behave more seriously.

    Thanks.

    Monday, October 21, 2013 6:52 AM