views:

71

answers:

0

Hi, I know is not very dificult code a WCF SelHosted WebService, my problem is i am not be able to invoke it from a non navigator, i am using to test it Curl, it's the same implement in this case?:

public class ddSoftWS
{


    [ServiceContract]
    public interface ITest
    {


        [OperationContract]
        [WebInvoke( Method = "POST",BodyStyle = WebMessageBodyStyle.Wrapped ,ResponseFormat = WebMessageFormat.Xml,RequestFormat = WebMessageFormat.Xml)]

        string  Test(string paramOne, int paramTwo);
    }
    public class Service : ITest
    {


        public string  Test(string paramOne, int paramTwo)
        {
            return "OK";
        }
    }
    public static void Test()
    {

        string baseAddress = "http://[servername]:8000/Service";
        ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
        WebHttpBinding biding = new WebHttpBinding();


        biding.Security.Mode = WebHttpSecurityMode.None;
        biding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
        biding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
        biding.Namespace = baseAddress;


        host.AddServiceEndpoint(typeof(ITest), biding, "");
        // configuramos el servicio



        host.Credentials.WindowsAuthentication.AllowAnonymousLogons = true;
        host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.None;
        host.Authorization.ImpersonateCallerForAllOperations = false;

        ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
        smb.HttpGetEnabled = true;
        host.Description.Behaviors.Add(smb);
        host.Open();


    }
}

This is the invoke from curl: curl -X POST -v -s -d "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap12:Envelope xmlns:xsi=\"http://www.w3.org/-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"&gt;&lt;soap12:Body&gt;&lt;Test xmlns=\"http://tempuri.org/\"&gt;&lt;paramOne&gt;prueba1&lt;/paramOne&gt;&lt;paramTwo&gt;666&lt;/paramTwo&gt;&lt;/Test&gt;&lt;/soap12:Body&gt;&lt;/soap12:Envelope&gt;" -H "Accept: application/soap+xml" -H "Content-Type: application/soap+xml" -H "SOAPAction: Test" http://[servername]:8000/Service.asmx and the response is Or bad Request (http:400) or Server Internal error (http:500)

What is wrong??? thanks in advance.