Php Client / .Net Webservice / Datetime problem - Urgent!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ramarnath@gmail.com

    Php Client / .Net Webservice / Datetime problem - Urgent!

    Problem in sending datatime format to the .net webservice from php.
    description follows.


    I've created a .net webservice.

    ..Net Webservice:

    <WebMethod()> _
    Public Function HelloDate(ByVal mydate As DateTime) As String
    mystr = mydate.ToString ("dddd") 'Which displays day
    Return mystr
    End Function

    Php Client:

    $parameters['mydate'] = "12 June 2005;
    $soap_proxy = $s->getProxy();
    $result = $soap_proxy->HelloDate($par ameters);
    if (!$err = $soap_proxy->getError()){
    echo($result["HelloDateResul t"]);
    }else{
    echo 'Error: ' . $err . "\n";
    }

    When i tried to communicate the .net webservice. It shows following
    error.

    "Error: soap:Client: Server was unable to read request. --> There is an
    error in XML document (1, 460). --> String was not recognized as a
    valid DateTime. "

    How to send datetime format data to the webservice from php. For
    String, Numbers above code works well.

  • Andy Hassall

    #2
    Re: Php Client / .Net Webservice / Datetime problem - Urgent!

    On 3 Jun 2005 10:16:12 -0700, ramarnath@gmail .com wrote:
    [color=blue]
    >Problem in sending datatime format to the .net webservice from php.
    >description follows.
    >
    >I've created a .net webservice.
    >
    >.Net Webservice:
    >
    > <WebMethod()> _
    > Public Function HelloDate(ByVal mydate As DateTime) As String
    > mystr = mydate.ToString ("dddd") 'Which displays day
    > Return mystr
    > End Function
    >
    >Php Client:
    >
    >$parameters['mydate'] = "12 June 2005;
    >$soap_proxy = $s->getProxy();
    >$result = $soap_proxy->HelloDate($par ameters);
    >if (!$err = $soap_proxy->getError()){
    > echo($result["HelloDateResul t"]);
    >}else{
    > echo 'Error: ' . $err . "\n";
    >}
    >
    >When i tried to communicate the .net webservice. It shows following
    >error.
    >
    >"Error: soap:Client: Server was unable to read request. --> There is an
    >error in XML document (1, 460). --> String was not recognized as a
    >valid DateTime. "
    >
    >How to send datetime format data to the webservice from php. For
    >String, Numbers above code works well.[/color]

    Having never used webservices this may be the wrong track, but I'd look at:



    "12 June 2005" doesn't look like the sort of thing a portable format would
    accept. 2005-06-12T00:00:00 looks more like it.

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • NC

      #3
      Re: Php Client / .Net Webservice / Datetime problem - Urgent!

      ramarnath@gmail .com wrote:[color=blue]
      >
      > I've created a .net webservice.
      >
      > .Net Webservice:
      >
      > <WebMethod()> _
      > Public Function HelloDate(ByVal mydate As DateTime) As String
      > mystr = mydate.ToString ("dddd") 'Which displays day
      > Return mystr
      > End Function[/color]

      Bad idea. Web services exchange data in text format and should
      be platform-independent. Consequently, the only argument type
      (and the only return type) allowed for a Web service method
      should be String.

      Rewrite your method:

      <WebMethod()> _
      Public Function HelloDate(ByVal myinput As String) As String
      if IsDate(myinput) Then
      mydate = CDate(myinput)
      mystr = mydate.ToString ("dddd")
      Return mystr
      Else
      ' handle the error; the supplied argument
      ' cannot be converted to date
      End If
      End Function
      [color=blue]
      > How to send datetime format data to the webservice from php.[/color]

      DateTime is a .NET-specific structure. You should avoid having
      to send to (or receive from) a Web service anything that is not
      string.

      Cheers,
      NC

      Comment

      • Ewoud Dronkert

        #4
        Re: Php Client / .Net Webservice / Datetime problem - Urgent!

        On 3 Jun 2005 10:16:12 -0700, ramarnath@gmail .com wrote:[color=blue]
        > $parameters['mydate'] = "12 June 2005;
        > $result = $soap_proxy->HelloDate($par ameters);[/color]

        In addition to the remarks made by Andy and NC, try passing the actual
        string, not an array.

        $result = $soap_proxy->HelloDate($par ameters['mydate']);


        --
        Firefox Web Browser - Rediscover the web - http://getffox.com/
        Thunderbird E-mail and Newsgroups - http://gettbird.com/

        Comment

        • ramarnath@gmail.com

          #5
          Re: Php Client / .Net Webservice / Datetime problem - Urgent!

          Thanks Andy,

          It wroks well. thanks a lot..

          $parameters['mydate'] = "2005-06-04T00:00:00";
          $soap_proxy = $s->getProxy();
          $result = $soap_proxy->HelloDate($par ameters);
          if (!$err = $soap_proxy->getError()){
          echo($result["HelloDateResul t"]);
          }
          else{
          echo 'Error: ' . $err . "\n";
          }


          Thanks for your effort.

          Thanks NC, Ewoud Dronkert.

          Comment

          Working...