Skip to content
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

feat(wsdl-meta): allow to customize message names for operation #1044

Merged
merged 2 commits into from
Jun 1, 2024

Conversation

Yozer
Copy link
Contributor

@Yozer Yozer commented Mar 29, 2024

I have several SOAP services and they generate different message names for operations.
This PR extends SoapCore so users can customize the input/output messages in whatever way they want.

@andersjonsson
Copy link
Collaborator

I'm thinking that this should be used in MetaWCFBodyWriter also. Thoughts?

@Yozer
Copy link
Contributor Author

Yozer commented May 30, 2024

Yep, definitely someone might want to customize it for WCF.
I'm not that familiar with the WCFBodyWriter as I only care about the MetaBodyWriter.
I assume we would need a different implementation there as the default names are probably different?

@andersjonsson
Copy link
Collaborator

As far as I can tell it's the same?

private void AddMessages(XmlDictionaryWriter writer)
{
foreach (var operation in _service.Operations)
{
// input
writer.WriteStartElement("wsdl", "message", Namespaces.WSDL_NS);
writer.WriteAttributeString("name", $"{BindingType}_{operation.Name}_InputMessage");
writer.WriteStartElement("wsdl", "part", Namespaces.WSDL_NS);
writer.WriteAttributeString("name", "parameters");
string inputElement = "tns:" + operation.Name;
if (operation.Contract.Name != BindingType)
{
var ns = $"q{_namespaceCounter++}";
writer.WriteXmlnsAttribute($"{ns}", operation.Contract.Namespace);
inputElement = $"{ns}:{operation.Name}";
}
writer.WriteAttributeString("element", inputElement);
writer.WriteEndElement(); // wsdl:part
writer.WriteEndElement(); // wsdl:message
// output
if (!operation.IsOneWay)
{
writer.WriteStartElement("wsdl", "message", Namespaces.WSDL_NS);
writer.WriteAttributeString("name", $"{BindingType}_{operation.Name}_OutputMessage");
writer.WriteStartElement("wsdl", "part", Namespaces.WSDL_NS);
writer.WriteAttributeString("name", "parameters");
string outputElement = "tns:" + operation.Name + "Response";
if (operation.Contract.Name != BindingType)
{
var ns = $"q{_namespaceCounter++}";
writer.WriteXmlnsAttribute($"{ns}", operation.Contract.Namespace);
outputElement = $"{ns}:{operation.Name}Response";
}
writer.WriteAttributeString("element", outputElement);
writer.WriteEndElement(); // wsdl:part
writer.WriteEndElement(); // wsdl:message
}
AddMessageFaults(writer, operation);
}
}

BindingType is confusingly named. It's set to service.GeneralContract.Name in the constructor

@Yozer
Copy link
Contributor Author

Yozer commented May 31, 2024

Added support for MetaWCFBodyWriter

@andersjonsson andersjonsson merged commit 789828c into DigDes:develop Jun 1, 2024
3 checks passed
@andersjonsson
Copy link
Collaborator

Looks good! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants