WCF - UriTemplate?



  • Good afternoon.

    I'm here with a question I can't understand myself.

    Question: What is UriTemplate and what is he eating with?

    I've dealt with specific examples. For example:

    [ServiceContract(Namespace = "urn:example:services")]
        public interface ISomeWcf
        {
            [WebInvoke(Method = "GET",
                ResponseFormat = WebMessageFormat.Xml,
                BodyStyle = WebMessageBodyStyle.Wrapped,
                UriTemplate = "GetResult?client={client}&password={password}&messageId={messageId}")]
            string GetResultHttpGet(string client, string password, string messageId);
    
     }
    

    In this particular case, UriTemplate seeks a template that we can use the GetResultHtpGet method through REST. I've read M.I.D., but I haven't.

    Why do you say Namespace = "urn:example:services"?

    You can tell me what's wrong. UriTemplate Do what? I feel like I'm walking around with the answer, and I can't formulate it.

    Thank you.



  • UriTemplate a template that determines whether the entry request for Uri data should be serviced GetResultHttpGetas well as comparing parts of Uri with the parameters of the method.

    Allow a base address for this contract

    http://hostname/SomeWcf/
    

    If an application (or direct browser) makes a GET request

    http://hostname/SomeWcf/GetResult?client=CLI&password=PWD&messageId=MSG
    

    Then the method GetResultHttpGet Service. In doing so, parts of Uri will become values of the relevant parameters:

    string GetResultHttpGet(string client, string password, string messageId)
    {
        //здесь части Uri станут значениями параметров:
        //client = "CLI";
        //password = "PWD";
        //messageId = "MSG";
        ...
    }
    

    If you're tossing off hats, pushing something else, for example.

    http://hostname/SomeWcf/GetResult2?name=NAME
    или
    http://hostname/SomeWcf/GetResult3/Name/Foo
    

    method GetResultHttpGet It won't be called.

    As to the properties Namespace Attribution ServiceContract

    [ServiceContract(Namespace = "my.company.com")]
    

    it's in the title soap-envelope.

    <s:Envelope ...>
      <s:Header>
        ...
        <a:Action s:mustUnderstand="1" ...>my.company.com/ISomeWcf/GetResultHttpGet</a:Action>
        ...
      </s:Header>
      <s:Body ...>
        ...
      </s:Body>
    </s:Envelope>
    

    If not specified

    [ServiceContract]
    

    instead my.company.com there will be a default value.http://tempuri.org)

    If the interface that describes the contract is in referred to by the client and server, in principle Namespace may be anyone. If the interface is described twice in the client and server section, or if you create a client for an already existing service with a certain degree. NamespaceNamespace We have to match the client and server to understand each other, otherwise the answer will be

    <s:Envelope ...>
      ...
      <s:Body>
        <s:Fault>
          ...
          <s:Reason>
            <s:Text xml:lang="en-US">
              The message could not be processed
              because the action 'http://tempuri.org/ISomeWcf/GetResultHttpGet'
              is invalid or unrecognized.
            </s:Text>
          </s:Reason>
        </s:Fault>
      </s:Body>
    </s:Envelope>
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2