How to Remove extra response tag from my Soap Response
I have below code for my service :
[XmlType(Namespace="http://djm.eu/services/sample/v1")]
[XmlRoot("MyResponse", Namespace="http://djm.eu/services/sample/v1", IsNullable=false)]
public class MyResponseType
{
public int Code { get; set; }
public string Description { get; set; }
}
[ServiceContract(Namespace = @"http://djm.eu/services/sample/v1")]
public interface IMyService
{
[OperationContract]
[return:MessageParameter(Name = "MyResponse")]
MyResponseType Foo();
}
public class MyService : IMyService
{
public MyResponseType Foo()
{
return new MyResponseType
{
Code = 200,
Description = "Ok"
};
}
}
and this is the result :
<s:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<FooResponse xmlns="http://djm.eu/services/sample/v1">
<MyResponse>
<Code>200</Code>
<Description>Ok</Description>
</MyResponse>
</FooResponse>
</s:Body>
</s:Envelope>
The problem is I dont want that extra <FooResponse> tag created automatically. I want it completely remove (SoapParameterStyle.Bare).
Expected result:
<s:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<MyResponse xmlns="http://djm.eu/services/sample/v1">
<Code>200</Code>
<Description>Ok</Description>
</MyResponse>
</s:Body>
</s:Envelope>
Thanks.
Yeah, I have the same problem. I commented out couple of code rows in this engine and now it's OK, doesn't duplicate, puts some extra default namespaces but that's OK, I can live with that. Pretty nasty solution I did but don't see better at the moment, maybe in the future!
fixed it here
Please, check https://www.nuget.org/packages/SoapCore/0.9.8.3
upd: https://www.nuget.org/packages/SoapCore/0.9.8.4
Seems that this is fixed pretty well n can be closed! Well done @DmitryBryluk !
why am i getting a "This XML file does not appear to have any style information associated with it. The document tree is shown below."
Has this issue been solved? @DmitryBryluk and @tomskarasha comments give that impression, but when I try the sample provided by @srigaux I still end up with a nested FooResponse and MyResponse which I was hoping to avoid. (FYI: my use case is to mock another external web service for testing purposes. But I am not able to re-create ws because I get this extra element in every soap action's request and response.)
it is explained in serialization tests. under some conditions you may avoid extra response tag, do not remember details
fixed it here
Can you put a example to how to do this, please? Maybe the correction of srigaux's code
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Has this issue been solved? @DmitryBryluk and @tomskarasha comments give that impression, but when I try the sample provided by @srigaux I still end up with a nested FooResponse and MyResponse which I was hoping to avoid. (FYI: my use case is to mock another external web service for testing purposes. But I am not able to re-create ws because I get this extra element in every soap action's request and response.)
Had a similar issue and was able to fix this usign MessageContract and MessageBodyMember. you can give it a try if you still facing this extra xml in the response.