0

Im calling a web service(C#) which generates a random number between (1 and 5) from php code using nusoap_client.The php code is as follows

$client = new nusoap_client('http://localhost/TestWebService/TestWebService.asmx?WSDL','TRUE');
//echo("execute". $client);
$result = $client->call('GenerateRandomNumber');
//echo("executerandomn".$result);
$return=redirectpage($result); //redirectpage() function redirects the user based on the random number generated.

The function GenerateRandomNumber() is returning null.I tried browsing the webservice separately its working but not when called through php.

The WSDL created is below

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"   xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"   xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="GenerateRandomNumber">
<s:complexType />
</s:element>
<s:element name="GenerateRandomNumberResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GenerateRandomNumberResult" type="s:int" />
      </s:sequence>
    </s:complexType>
  </s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="GenerateRandomNumberSoapIn">
<wsdl:part name="parameters" element="tns:GenerateRandomNumber" />
</wsdl:message>
<wsdl:message name="GenerateRandomNumberSoapOut">
<wsdl:part name="parameters" element="tns:GenerateRandomNumberResponse" />
</wsdl:message>
<wsdl:portType name="TestWebServiceSoap">
<wsdl:operation name="GenerateRandomNumber">
  <wsdl:input message="tns:GenerateRandomNumberSoapIn" />
  <wsdl:output message="tns:GenerateRandomNumberSoapOut" />
  </wsdl:operation>
        </wsdl:portType>
 <wsdl:binding name="TestWebServiceSoap" type="tns:TestWebServiceSoap">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
  <wsdl:operation name="GenerateRandomNumber">
  <soap:operation soapAction="http://tempuri.org/GenerateRandomNumber" style="document" />
  <wsdl:input>
    <soap:body use="literal" />
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal" />
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="TestWebServiceSoap12" type="tns:TestWebServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GenerateRandomNumber">
    <soap12:operation soapAction="http://tempuri.org/GenerateRandomNumber"  style="document" />
   <wsdl:input>
    <soap12:body use="literal" />
    </wsdl:input>
    <wsdl:output>
    <soap12:body use="literal" />
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="TestWebService">
    <wsdl:port name="TestWebServiceSoap" binding="tns:TestWebServiceSoap">
     <soap:address location="http://localhost/TestWebService/TestWebService.asmx" />
      </wsdl:port>
      <wsdl:port name="TestWebServiceSoap12" binding="tns:TestWebServiceSoap12">
     <soap12:address location="http://localhost/TestWebService/TestWebService.asmx" />
     </wsdl:port>
     </wsdl:service>
     </wsdl:definitions>

Please Help.

4
  • Could u pls tel me instead of soap, what should i use? Commented Jun 18, 2013 at 7:44
  • Build your webservice in a RESTful way, you can find a starting point petefreitag.com/item/431.cfm or xfront.com/REST-Web-Services.html. And here is a C# library which can be interesting : restsharp.org Commented Jun 18, 2013 at 8:11
  • So what ever the method(code) i have followed is wrong? So using soap cant i achieve the above scenario? Thanks in Advance Commented Jun 20, 2013 at 7:16
  • I've been a little bit sarcastic (sorry) : using SOAP can achieve your goal, but in my opinion SOAP is too heavy and too slow, I personally prefer using RESTful webservices. Commented Jun 21, 2013 at 6:30

1 Answer 1

1

HI maybe this WSDL to Php converter can help you http://www.wsdltophp.com/ it can make functions to make request and get responses correctly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.