O
O
Ogoun Er2012-08-08 12:13:37
Programming
Ogoun Er, 2012-08-08 12:13:37

Why are parameters not being passed?

Service code:

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
        [SoapDocumentMethod("Ping")]
        public string Ping(string pingString)
        {
            return pingString;
        }
    }


Proxy to call the Ping method on the web service:
    [WebServiceBinding("PingServer.Service1")]
    public class PingServiceProxy : SoapHttpClientProtocol
    {
        public PingServiceProxy()
        {
            base.Url = "http://localhost:53366/Service1.asmx";
        }

        [WebMethod]
        [SoapDocumentMethod("Ping")]
        public string Ping(string pingString)
        {
            return (string)base.Invoke("Ping", new object[] { pingString })[0];
        }
    }


The call itself:
    using (PingServiceProxy proxy = new PingServiceProxy())
            {
                Console.WriteLine(proxy.Ping("Hello, World!"));
            }


The call goes well, the proxy accesses the service, but the method receives null instead of a string, I can’t understand the reason. Moreover, if you call the method, for example, from the browser, the parameter comes normally. Those. the jamb turns out in implementation of a proxy.

It is not worth suggesting the use of WCF or other methods, you need an implementation in this way (and it is on .net no higher than the second Framework)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
qw1, 2012-08-08
@qw1

the client is missing the Namespace parameter in the WebServiceBinding attribute

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question