-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "bad namespace for Body, found http://schemas.xmlsoap.org/soap/envelope/" #177
Comments
Hello @averichev , Sorry for the delay. #[derive(YaDeserialize, YaSerialize)]
#[yaserde(flatten)]
pub enum BodyEnum {
#[yaserde(rename="Fault", prefix="soap", flatten)]
Fault(Fault),
#[yaserde(rename="GetMessageResponse", prefix="soap", flatten)]
GetMessageResponse(GetMessageResponse),
} I'm not sure the library handle multi And if you get against an error, then it's mostly a bug on namespace with enums. Best, |
I think I am having the same issue. I tried to produce a minimal example: use yaserde::*;
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(
rename = "base",
namespace = "http://base/",
namespace = "ns1: http://ns1/",
namespace = "ns2: http://ns2/"
)]
pub struct Base {
#[yaserde(rename = "data", prefix = "ns1")]
pub data: Ns2DataItemType,
}
#[derive(YaDeserialize, Debug, PartialEq, Default)]
#[yaserde(prefix = "ns2", namespace = "ns2: http://ns2/")]
pub enum Ns2DataItemType {
#[yaserde(rename = "dataItem", prefix = "ns2")]
DataItem(String),
#[default]
#[allow(non_camel_case_types)]
__undefined__,
}
#[test]
fn mixed_namespaces() {
use yaserde::de::from_str;
let content = r#"
<base
xmlns="http://base/"
xmlns:ns1="http://ns1/"
xmlns:ns2="http://ns2/">
<ns1:data>
<ns2:dataItem>value1</ns2:dataItem>
</ns1:data>
</base>
"#;
let loaded: Base = from_str(content).unwrap();
println!("{:?}", loaded);
let reference = Base {
data: Ns2DataItemType::DataItem("value1".to_string()),
};
assert_eq!(loaded, reference);
} This results in
Edit: reduced example |
To double check that I wasn't misusing the library I tried to serialize Base to string <?xml version="1.0" encoding="utf-8"?><base xmlns="http://base/" xmlns:ns1="http://ns1/" xmlns:ns2="http://ns2/"><ns1:data><ns2:dataItem>value1</ns2:dataItem></ns1:data></base> |
I could work-around the issue by removing the namespace matching for the enum as it doesn't seem to affect the deserialization result in any way and is just there to provide the error "bad namespace for ...". Specifically I commented out this line
|
Error on deserialize
Link to test
Is this my mistake in using the library or a bug?
The text was updated successfully, but these errors were encountered: