I’m struggling to get my head around creating a basic definition for WSDL to process a simple login.
I’m creating a service that I’m calling uQuizService.
At the moment it is really in it’s infancy, I wish to create an operation. I have a port called uQuizMembership and an operation called DoLogin which is processed by a PHP Script.
Desired input and outputs for DoLogin:
loginRequest: I wish for this to take a USERNAME and PASSWORD as
strings.loginResponse: I wish to return the generated SESSION_ID as
a string.
At the moment the input, is specified as a single string (I think :/).
I’m not sure how I specify a USERNAME and PASSWORD for the loginRequest input to the DoLoginoperation.
Here’s my WSDL file so far:
<?xml version="1.0"?>
<wsdl:definitions name="uQuizSOAP"
targetNamespace="urn:uQuizSoap"
xmlns:tns="urn:uQuizSoap"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:service name="uQuizService">
<port name="uQuizPort" binding="uQuizBinding">
<soap:address location="http://uquiz/soap_server.php" />
</port>
</wsdl:service>
<wsdl:portType name="uQuizMembership">
<wsdl:operation name="DoLogin">
<wsdl:input message="tns:loginRequest" />
<wsdl:output message="tns:loginResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:message name="loginRequest">
<part name="username" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="loginResponse">
<part name="login_session_id" type="xsd:string" />
</wsdl:message>
<wsdl:binding name="uQuizBinding" type="tns:uQuizPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="DoLogin">
<soap:operation soapAction="urn:xmethods-delayed-quotes#DoLogin" />
<wsdl:input>
<soap:body use="encoded" namespace="urn:xmethods-delayed-quotes"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/'" />
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="urn:xmethods-delayed-quotes"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
My Problems:
I’m not sure if the input and output definitions are correct within the binding as it currently stands.
I’m not sure how to change it to accept username and password strings instead of just a single string.
Thanks for your help
First of all, the WSDL you posted is not valid. In the service section, the port binding is set to
uQuizBindingwhen it should betns:uQuizBindingwhile in the binding section the type attribute is set to
tns:uQuizBindingwhen I think it should betns:uQuizMembershipAnd the request is indeed specified as a single string (just the
username) because you only defined one part for the message:Fix these items and you should get requests and responses that look like this:
Also please be aware that you are using RPC/encoded style which isn’t the recommended one for interoperability. See this article for some guidelines: Which style of WSDL should I use? and maybe look at an working example which uses document/literal style: http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx
You might also want to make this secure since you are doing a login operation 🙂