DigDes / SoapCore

SOAP extension for ASP.NET Core
MIT License
977 stars 369 forks source link

How to specify custom name for <wsdl:message> #484

Open sankakiran opened 4 years ago

sankakiran commented 4 years ago

We are planning to migrate existing WCF services to .Net core. Service consumers should not be impacted with this code migration. So we have to produce the same wsdl similar to WCF. I found message name difference in generated wsdl compared to old wsdl, which required changes at client end.

SoapCore:

<wsdl:message name = "MemberSoap_addMember_InputMessage">
   <wsdl:part name = "parameters" element = "tns:addMember" />
</wsdl:message>
<wsdl:portType name = "MemberSoap">
   <wsdl:opertion name = "addMember">
       <wsdl:input message = "MemberSoap_addMember_InputMessage" />
   </wsdl:operation>
</wsdl:portType>

WCF:

<wsdl:message name = "MemberSoapIn">
   <wsdl:part name = "parameters" element = "tns:addMember" />
</wsdl:message>
<wsdl:portType name = "MemberSoap">
   <wsdl:opertion name = "addMember">
       <wsdl:input message = "MemberSoapIn" />
   </wsdl:operation>
</wsdl:portType>

I tried with "MessageContractAttribute" but not reflected in wsdl. We need help to rename the message name.

kotovaleksandr commented 4 years ago

Hi! Are you sure what message name impact for service behavior? Whats differ MemberSoap_addMember_InputMessage against MemberSoapIn? Its simple alias for operations, it can be message1, message2 or something else. Its not a part of contract.

https://www.w3.org/TR/wsdl.html#_messages

You have specific problems with web service on soapcore and client interaction?

sankakiran commented 4 years ago

one of our application consumers have hard coded the message names. So we need same message name to be reflected with SoapCore.

kotovaleksandr commented 4 years ago

No, again: message name is not a part of contract, you can't hardcode them. Example, my service definition: image

And method call throw SoapUI: image

Message name doesn't affect to client-server communication. You can't set them on any framework, it's internal detail of WSDL generator implementation.

If your client application which generate client code by WSDL except specific message names pattern - it's not correct, by specification message name can be any unique string.

Please describe concrete problem.

sankakiran commented 4 years ago

If there is change in message names then request and response objects are become Null. Client application is on Seibel technology where as they have hard coded the message names. This is only issue with this seibel client and rest of the applications are not impacted with name change. We had similar problem when we migrate webservice (asmx) to wcf (svc) and it was resolved by adding MessageContracts to override the message name. If there is no option then will ask our app consumers to change their code.

jrwarwick commented 3 years ago

I've run into a scenario similar to sankakiran. In addition to the message names, it is not clear to me how (or if I can) control the portType name (without doing something weird to the interface class names or something). Even though what SoapCore is doing is technically sound and maps nicely between the WSDL and the source, sometimes you are just dealing with large companies that are very, very difficult to even communicate with, let alone persuade to make a change. If I cannot make a transparent drop-in replacement (that will pass all of their mysterious validation checks and so on) I'm probably out of luck (as I'm sure sankakiran ended up).

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 years ago

This issue was closed because it has been inactive for 14 days since being marked as stale.

Ogabek-Kholmirzaev commented 1 month ago

We are planning to migrate existing WCF services to .Net core. Service consumers should not be impacted with this code migration. So we have to produce the same wsdl similar to WCF. I found message name difference in generated wsdl compared to old wsdl, which required changes at client end.

SoapCore:

<wsdl:message name = "MemberSoap_addMember_InputMessage">
   <wsdl:part name = "parameters" element = "tns:addMember" />
</wsdl:message>
<wsdl:portType name = "MemberSoap">
   <wsdl:opertion name = "addMember">
       <wsdl:input message = "MemberSoap_addMember_InputMessage" />
   </wsdl:operation>
</wsdl:portType>

WCF:

<wsdl:message name = "MemberSoapIn">
   <wsdl:part name = "parameters" element = "tns:addMember" />
</wsdl:message>
<wsdl:portType name = "MemberSoap">
   <wsdl:opertion name = "addMember">
       <wsdl:input message = "MemberSoapIn" />
   </wsdl:operation>
</wsdl:portType>

I tried with "MessageContractAttribute" but not reflected in wsdl. We need help to rename the message name.

Hi, are you able to change MenberSoap_receivePayment_InputMessage in SoapCore?

andersjonsson commented 1 month ago

There is no built in way to override the naming and changing the default behavior in SoapCore could break existing code for a lot of people.

You are more than welcome to submit a PR with an override option. I'm not sure if using MessageContractAttribute, or adding custom attributes to the operation method is the cleanest solution. What do you think?

andersjonsson commented 1 month ago

It is also worth noting that differing message names shouldn't matter in most cases. I was able to switch my legacy service without breaking anyone even though the message name in the wsdl was altered. I might be missing something but I think the only case that would break is if someone has hard-coded wsdl-verification that requires a specifik message name

Ogabek-Kholmirzaev commented 1 month ago

@andersjonsson Could you help me with WSDL template. Given a WSDL template to me to implement server side soap service. I need to do the same to the given WSDL. I couldn't do it in SoapCore. How could I do it?

If you could help me, send me email address or any social app account adress I will send you the WSDL template.

andersjonsson commented 1 month ago

No, unfortunately I'm not going to be able to help you with that.

andersjonsson commented 1 month ago

I just remembered that this PR https://github.com/DigDes/SoapCore/pull/1044 already implements the ability to change naming strategy for the input-output messages. Hopefully it can be merged quite soon

Ogabek-Kholmirzaev commented 1 month ago

image image image image

@andersjonsson I need you help. Sorry for interrupting again. Thank you your answer in advance!

I'm using SoapCore package. I have a getSubject method in SOAP interface. As you see, this method has 2 parametres(settlement & List subject). In the subject parameter, its type is ArrayOfSubjectinfo. I need to change this to subjectinfo, I can do it below in the payment class.

andersjonsson commented 1 month ago

I'm not sure that I understand what you're trying to do here, but you can solve this with a custom class

[XmlType(TypeName = "subject")]
public class SubjectList: List<SubjectInfo>
{
    public SubjectList(int capacity)
    {
        Capacity = capacity;
    }

    public SubjectList()
    {
    }
}

Then use that type as your parameter instead of List

Ogabek-Kholmirzaev commented 1 month ago

image

After this, I need to make unbounded in WSDL. How can I do it?

andersjonsson commented 1 month ago

That type becomes a complextype that is marked as unbounded (in the type declaration within your WSDL). My guess is that this wsdl will work in your use case even though it differs slightly from the original one.

I can't think of a way to make it unbounded on that level and still be able to specify the type name, so I can't help you with this

andersjonsson commented 1 month ago

No, I can't help you any more than I already have.

github-actions[bot] commented 4 days ago

This issue is stale because it has been open for 30 days with no activity.