HTTP Content-Type required exception with Soap12 client

I’m in the process of making our API support SOAP but a WebServiceException is thrown every time, “An HTTP Content-Type header is required for SOAP messaging and none was found.”. Looking at the source code what I’m doing below should work just fine.

[Test]
public void GetDevice_Soap12_AsExpected()
{
    using (var soapClient = new Soap12ServiceClient("http://localhost:8088/"))
    {
	GetDevice request = new GetDevice()
	{
		Id = 1,
	};

	GetDeviceResponse response = soapClient.Send<GetDeviceResponse>(request);
    }
}

Please include the full class definition of the DTOs and the method signature of the Service this is calling.

DTO

[Route("/api/device")]
[DataContract]
public class GetDevices : IReturn<GetDevicesResponse>
{
    [DataMember]
    public int Id { get; set; }
}

[DataContract]
public class GetDevicesResponse

Service

public object Any(GetDevices request)

I’ve created a new ServiceStack ASP.NET Empty and added this Service:

public class MyServices : Service
{
    public object Any(GetDevices request)
    {
        return new GetDevicesResponse();
    }
}

Using the GetDevice DTOs provided:

[Route("/api/device")]
[DataContract]
public class GetDevices : IReturn<GetDevicesResponse>
{
    [DataMember]
    public int Id { get; set; }
}

[DataContract]
public class GetDevicesResponse { }

And the SoapTest is working without Exception:

[Test]
public void Can_call_GetDevices_with_Soap12ServiceClient()
{
    var client = new Soap12ServiceClient("http://localhost:49488/");

    var response = client.Send(new GetDevices());
}

Please fork the TestApp repo and modify it so that the SoapTest repros the issue.

There was an issue in my code related to setting the Namespace. This issue has been resolved.

[assembly: ContractNamespace("http://schemas.servicestack.net/types", 
       ClrNamespace = "<YOUR NAMESPACE>")]
1 Like