locked
I can't use this wsdl . RRS feed

  • Question

  • Hello. I wanna Use this URL : http://www.smsmelli.com/class/sms/webservice/server.php?wsdl that is a web service to send SMS. when I add it to my references it add, but when i want to write a code it is like that there isn't this web service . i try with another web service they worked very good but this WSDL  file doesn't work . can any one check it and say me why it doesn't work ?
    Saturday, January 14, 2012 10:55 AM

Answers

  • You will need to see what your friend is doing on the c++ side, but here is the basic c# version.  When I call this method from a console app, the server responds with a bad username/password was sent message, so it seems the server is listening to the request.  Your friends code presumably sets up a valid username/password on the request.
     
      static void CallService()
      {
       string methodName = "GetCredit";
       string url = "
    http://www.smsmelli.com/class/sms/webservice/server.php";
       HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(url);
     
       httpRequest.ContentType = "text/xml; charset=utf-8";
       httpRequest.Headers.Add("SOAPAction:
    http://tempuri.org/" + methodName);
       httpRequest.ProtocolVersion = HttpVersion.Version11;
       httpRequest.Method = "POST";
       Stream requestStream = httpRequest.GetRequestStream();
     
       //Create Stream and Complete Request             
       StreamWriter streamWriter = new StreamWriter(requestStream, Encoding.ASCII);
     
       StringBuilder soapRequest = new StringBuilder(
    "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
       soapRequest.Append(" xmlns:xsd=\"
    http://www.w3.org/2001/XMLSchema\" ");
       soapRequest.Append("xmlns:soap=\"
    </'>http://tempuri.org/\"></" + methodName + ">");
       soapRequest.Append("</soap:Body></soap:Envelope>");
     
       streamWriter.Write(soapRequest.ToString());
       streamWriter.Close();
     
       //Get the Response    
       HttpWebResponse wr = (HttpWebResponse)httpRequest.GetResponse();
       StreamReader srd = new StreamReader(wr.GetResponseStream());
       string resulXmlFromWebService = srd.ReadToEnd();
       Console.WriteLine(resulXmlFromWebService);
      }

     

    --
    Mike
    Sunday, January 15, 2012 6:41 PM

All replies

  • please help me

     

    Sunday, January 15, 2012 4:28 AM
  • I have written this.

    http://chanmingman.wordpress.com/2010/12/17/simplest-asynchronous-web-service-call-c/

    Provide your code and error here so people are easy to help you. 

    chanmm


    chanmm
    Sunday, January 15, 2012 8:31 AM
  • Pooria,

    Did you use WCF for that (the replacement for webservices)?

    http://msdn.microsoft.com/en-us/netframework/aa663324.aspx

    You see also the special forum fore that on that page.


    Success
    Cor
    Sunday, January 15, 2012 9:20 AM
  • I get three warnings and an error when adding this url as a web service (Visual Studio 2010/.net 4.0).
     
    The header of the url includes an email/contact, which you should use.  It seems there is a problem serverside that needs fixing before you have a chance of using this code.

    --
    Mike
    • Proposed as answer by Horizon_Net Sunday, January 15, 2012 1:15 PM
    Sunday, January 15, 2012 12:18 PM
  • I have written this.

    http://chanmingman.wordpress.com/2010/12/17/simplest-asynchronous-web-service-call-c/

    Provide your code and error here so people are easy to help you. 

    chanmm


    chanmm
    please say me here what should i do . Unfortunately your website is filter in my country .
    Sunday, January 15, 2012 1:32 PM
  • Pooria,

    Did you use WCF for that (the replacement for webservices)?

    http://msdn.microsoft.com/en-us/netframework/aa663324.aspx

    You see also the special forum fore that on that page.


    Success
    Cor
    No I don't use wcf . i make a windows form application and add a service reference .
    Sunday, January 15, 2012 1:32 PM
  • I get three warnings and an error when adding this url as a web service (Visual Studio 2010/.net 4.0).
     
    The header of the url includes an email/contact, which you should use.  It seems there is a problem serverside that needs fixing before you have a chance of using this code.

    --
    Mike
    yes there is an error . but my friend is using this web service in c++ and there isn't any problem .
    Sunday, January 15, 2012 1:33 PM
  • It may be possible to directly call the service via http POST commands using an HttpWebRequest object, rather than binding to the service in .Net.  Without seeing the C++ code, my guess is that is what your friend is doing.
     

    --
    Mike
    Sunday, January 15, 2012 4:24 PM
  • May you write a sample work that do some thing like this that you said?
    Sunday, January 15, 2012 6:14 PM
  • You will need to see what your friend is doing on the c++ side, but here is the basic c# version.  When I call this method from a console app, the server responds with a bad username/password was sent message, so it seems the server is listening to the request.  Your friends code presumably sets up a valid username/password on the request.
     
      static void CallService()
      {
       string methodName = "GetCredit";
       string url = "
    http://www.smsmelli.com/class/sms/webservice/server.php";
       HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(url);
     
       httpRequest.ContentType = "text/xml; charset=utf-8";
       httpRequest.Headers.Add("SOAPAction:
    http://tempuri.org/" + methodName);
       httpRequest.ProtocolVersion = HttpVersion.Version11;
       httpRequest.Method = "POST";
       Stream requestStream = httpRequest.GetRequestStream();
     
       //Create Stream and Complete Request             
       StreamWriter streamWriter = new StreamWriter(requestStream, Encoding.ASCII);
     
       StringBuilder soapRequest = new StringBuilder(
    "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
       soapRequest.Append(" xmlns:xsd=\"
    http://www.w3.org/2001/XMLSchema\" ");
       soapRequest.Append("xmlns:soap=\"
    </'>http://tempuri.org/\"></" + methodName + ">");
       soapRequest.Append("</soap:Body></soap:Envelope>");
     
       streamWriter.Write(soapRequest.ToString());
       streamWriter.Close();
     
       //Get the Response    
       HttpWebResponse wr = (HttpWebResponse)httpRequest.GetResponse();
       StreamReader srd = new StreamReader(wr.GetResponseStream());
       string resulXmlFromWebService = srd.ReadToEnd();
       Console.WriteLine(resulXmlFromWebService);
      }

     

    --
    Mike
    Sunday, January 15, 2012 6:41 PM
  • I have an another problem . In VISUAL STUDIO COMMAND PROMPT  when i write this code 

    wsdl /out:SmsClass.cs http://smsmelli.com/class/sms/webservice/server.php?wsdl

    these error appeared. :

    Error : unable to import binding 'Gwibinding'  from namespace 'urn:SMSServer'.

         - Unable to import operation 'Getcredit'.

         -The datatype 'http://schemas.xmlsoap.org/soap/encoding/:Array' is missing

     

     

    Monday, January 16, 2012 10:56 AM
  • how can i setup user name and password for this webservice?

     

    Monday, January 16, 2012 10:57 AM
  • Pooria,

    Did you use WCF for that (the replacement for webservices)?

    http://msdn.microsoft.com/en-us/netframework/aa663324.aspx

    You see also the special forum fore that on that page.


    Success
    Cor
    No I don't use wcf . i make a windows form application and add a service reference .
    Why do you then not use WCF, it is created to deal with WSDL services in C# for every type of application.
    Success
    Cor
    Monday, January 16, 2012 11:29 AM
  • i know this . but i don't have enough information about this . can any one answer my question?
    Monday, January 16, 2012 1:01 PM
  • Pooria,

    Did you use WCF for that (the replacement for webservices)?

    http://msdn.microsoft.com/en-us/netframework/aa663324.aspx

    You see also the special forum fore that on that page.


    Success
    Cor
    No I don't use wcf . i make a windows form application and add a service reference .
    Why do you then not use WCF, it is created to deal with WSDL services in C# for every type of application.
    Success
    Cor


    may you make a wcf program that work with that web service with this user name and password ?

    user:kakoli

    pass:123456

    Monday, January 16, 2012 1:27 PM
  • i know this . but i don't have enough information about this . can any one answer my question?

    On that link I gave you there is all kind of doors to information including the special forum for your wsdl 

    http://msdn.microsoft.com/en-us/netframework/aa663324.aspx

    What do you mean with answer your question? Do your job?


    Success
    Cor
    Monday, January 16, 2012 1:43 PM
  • i know this . but i don't have enough information about this . can any one answer my question?

    On that link I gave you there is all kind of doors to information including the special forum for your wsdl 

    http://msdn.microsoft.com/en-us/netframework/aa663324.aspx

    What do you mean with answer your question? Do your job?


    Success
    Cor

    my question is this :

    I have an another problem . In VISUAL STUDIO COMMAND PROMPT  when i write this code 

    wsdl /out:SmsClass.cs http://smsmelli.com/class/sms/webservice/server.php?wsdl

    these error appeared. :

    Error : unable to import binding 'Gwibinding'  from namespace 'urn:SMSServer'.

         - Unable to import operation 'Getcredit'.

         -The datatype 'http://schemas.xmlsoap.org/soap/encoding/:Array' is missing

    Monday, January 16, 2012 2:44 PM
  • if you make a wcf program whit that web service i will be ashamed .
    Monday, January 16, 2012 3:00 PM
  • please help me Cor Ligthert
    Monday, January 16, 2012 4:13 PM
  • Please post your friend's code that works in C++.
     

    --
    Mike
    Monday, January 16, 2012 9:24 PM

  • I am fairly certain that is the same error you get when you add the web reference in visual studio.  Why are you trying to do that?

    --
    Mike
    Monday, January 16, 2012 9:25 PM
  • I tried my code with the supplied credentials, and got a 102 error (username, password do not match).
     
    Probably not a good idea to post that, by the way...

     
     

    --
    Mike
    Monday, January 16, 2012 9:59 PM
  • ok i told you the user name and password . user name :kakoli password:123456. unfortunatly my friend is in another city now and i can't post his code because i don't have that . 
    Tuesday, January 17, 2012 4:55 AM
  • I guess we are at an impasse until we can see how your friends code passes the username/password, as setting the credentials on the webrequest fails with a 102 status.

    --
    Mike
    Wednesday, January 18, 2012 12:37 AM
  • I found the problem . in the wsdl file we have a word "Array" that it isn't known in .net . so we should change this word to another to use this wsdl file . do you have any idea?

    Note:the word array is in lines: 6,19

     

    <?xml version="1.0" encoding="utf-8"?>
    <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:typens="urn:SMSServer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="SMSServer" targetNamespace="urn:SMSServer" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
      <wsdl:types />
      <wsdl:message name="GetCredit" />
      <wsdl:message name="GetCreditResponse">
        <wsdl:part name="GetCreditReturn" type="soapenc:Array">
          <documentation>An array containing 'state', 'message', 'errnum', 'credit' keys</documentation>
        </wsdl:part>
      </wsdl:message>
      <wsdl:message name="enqueue">
        <wsdl:part name="from" type="xsd:string" />
        <wsdl:part name="rcpt_array" type="xsd:anyType" />
        <wsdl:part name="msg" type="xsd:anyType" />
        <wsdl:part name="type" type="xsd:string">
          <documentation>Can be 'normal', 'wap', 'flash' for different message types</documentation>
        </wsdl:part>
      </wsdl:message>
      <wsdl:message name="enqueueResponse">
        <wsdl:part name="enqueueReturn" type="soapenc:Array">
          <documentation>An array containing 'state', 'message', 'errnum', 'cost', 'batchid' keys</documentation>
        </wsdl:part>
      </wsdl:message>
      <wsdl:portType name="gwiPortType">
        <wsdl:operation name="GetCredit">
          <documentation>Get user remained credit</documentation>
          <wsdl:input message="typens:GetCredit" />
          <wsdl:output message="typens:GetCreditResponse" />
        </wsdl:operation>
        <wsdl:operation name="enqueue">
          <documentation>Add a message in queue, message encoding will be determined automatically </documentation>
          <wsdl:input message="typens:enqueue" />
          <wsdl:output message="typens:enqueueResponse" />
        </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="gwiBinding" type="typens:gwiPortType">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
        <wsdl:operation name="GetCredit">
          <soap:operation soapAction="urn:gwiAction" />
          <wsdl:input>
            <soap:body use="encoded" namespace="urn:SMSServer" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="encoded" namespace="urn:SMSServer" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="enqueue">
          <soap:operation soapAction="urn:gwiAction" />
          <wsdl:input>
            <soap:body use="encoded" namespace="urn:SMSServer" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="encoded" namespace="urn:SMSServer" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="SMSServerService">
        <wsdl:port name="gwiPort" binding="typens:gwiBinding">
          <soap:address location="http://www.smsmelli.com/class/sms/webservice/server.php" />
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>
    


     


    Friday, January 20, 2012 6:41 AM
  • please help me . thanks
    Friday, January 20, 2012 11:36 AM
  • Do you own the server and can you change the wsdl?
     
    There are plenty of examples on the web of how to set up wsdl returning an array from a method.  Just google "wsdl datatype array example", and you get hits such as this.

    If you do not own the site you are trying to hit, then you are talking to the wrong group here.  You need to contact the server owner.  If you do own the server, then you are in the wrong forum as setting up the service is more of an ASP.Net or php or whatever server technology is in use question.

    --
    Mike
    Friday, January 20, 2012 2:03 PM