Reputation: 21
I have a client with a Java soap interface. The WSDL is provided and i have to implement a server that reproduces it. The issue is that i wasn't able to fine tune my spyne made WSDL to reproduce exactly the WSDL provided and after looking into the spyne API, i think it is missing the options to do it (i would gladly be wrong about it !). Typically, i have three issues :
Can't cutomize the value of the field "name" and only it in wsdl:part (it takes the name of the exposed service and add "Response"):
<wsdl:message name="monitorDisseminationResponse">
<wsdl:part name="monitorDisseminationResponse" element="tns:monitorDisseminationResponse"/>
</wsdl:message>
Can't cutomize the fields name and type and only them in wsdl:binding (it takes the name of the application) :
<wsdl:binding name="DisseminationImplService" type="tns:DisseminationImplService">
Can't customize the field "name" and only it in wsdl:port wsdl:service name="DisseminationImplService">
<wsdl:service>
<wsdl:port name="DisseminationImplService" binding="tns:DisseminationImplService">
<soap:address location="http://sample:9000/Dissemination"/>
</wsdl:port>
</wsdl:service>
So, i am wondering how to move forward and would welcome some advice.
Upvotes: 1
Views: 872
Reputation: 21
Ok, i dig deeper into the API and think i found a solution for my issues with some monkey patching in the spyne/interface/wsdl/wsdl11.py
For issue #1, i didn't bother to make the change but it should be solvable the same way as #2 and #3
Issue #2 can be solved by monkey patching the method :
from spyne.interface.wsdl.wsdl11 import Wsdl11
def _get_binding_name(self, port_type_name):
if port_type_name == "NameIDoNotWant":
port_type_name = "NameIWant"
return port_type_name # subclasses override to control port names.
Wsdl11._get_binding_name = _get_binding_name
for #3, i used the __port_types__
class attribute for my service class :
class DisseminationImplService(ServiceBase):
__port_types__ = ['Dissemination']
@srpc(Unicode, Unicode, DisseminationInfo, _port_type='Dissemination', _returns=DisseminateResponse)
But, there was a nasty trick, there is currently (23/07/18) a bug in spyne (see issue #571) with a fix that has not yet been merged. Without it, the port will not have the transport key in the wsdl.
Finally, you need to monkey patch the port name in the wsdl :
def _add_port_to_service(self, service, port_name, binding_name):
""" Builds a wsdl:port for a service and binding"""
### spyne code####
if port_name == "NameIDoNotWant":
wsdl_port.set('name', "NameIWant")
else:
wsdl_port.set('name', port_name)
### spyne code####
Wsdl11._add_port_to_service = _add_port_to_service
Upvotes: 1