C# DateTime type over web service with PHP & SOAP

F0G

I work with web services written in C#, with PHP on my (client) side.

SOAP __getTypes returns that one of the expected parameter to be dateTime birthDate. I tried to send parameter in different ways, like

$date = new DateTime("now");
$wsclient->SomeFunction(array($date->format("Y-m-d\TH:i:s"));

or $date->format('c') I even wrote it just as a string 1932-11-12T00:00:00 and so on. I do not get soap exception, but function returns that received birthDate value was 0001-01-01T00:00:00.

I had a meeting with the developer of web services and he showed me that when he passes System.DateTime type variable to the function it works properly, but he did it locally in C# and not over the web service, just doing

date = new DateTime(1999,9,9,0,0,0);
SomeFunction(date);

What i want to know is how can i pass c# DateTime type from PHP. I guess that i'm doing it right with $date->format('c') or with $date->format("Y-m-d\TH:i:s").

I just want to make sure that this part of code is right and if so, search for problem in other place.

UPDATE: What we came to is: they changed code on their side. Data type remains the same (DateTime), I don't have an idea what they did there, but if I get any information, I'll keep this post up to date.

After few years: They just had no idea what they were doing and I got stuck with a problem, that was just impossible to solve by my side. If WSDL requests DateTime and you send it properly (SOAP doesn't throw an exception) and it doesn't work as it should, than you should be looking for the problem on the other end, for sure.

Stigmha

"... I had a meeting with the developer of web services and he showed me that when he passes System.DateTime type variable to the function it works properly, but he did it locally in C# ..."

The function you try to invoke in the C# web service takes a System.DateTime object as a parameter. I looked it up at MSDN and learned that it is a C# class. PHP's DateTime Class is not the same, so the service probably recognizes an instance of PHP's DateTime class as invalid data. I am not sure how communication works with C# services, but I would assume that it requires a binary representation of a C# System.DateTime object. It means that you could potentially investigate how C#'s System.DateTime object is represented in binary and manually construct and pass the binary data in PHP. This is however incredible time consuming and you have no gurantee that it will actually work.

A better solution would be to use another function in the web service (if it exists) that retrieve primitime data types as parameters instead of C# specific classes. An example would be a similar function in the web service that retrieves an Unix timestamp (in PHP: time()) which the function can use to create its own System.DateTime C# object. Another example could be a function retrieving a date from a formatted string (e.g. "dd.mm.yyy H:i:s").

It would be easier to help you if you were able to retireve the web service developer's local code/example (the one you mentioned) and post it here.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Securing a PHP Web service (SOAP)

分類Dev

using javascript fetch API with a SOAP web service

分類Dev

Java connect to SOAP web service using SSL handshake failure

分類Dev

How can I use SOAP web service on REST App

分類Dev

How to script SOAP based web service using SUDS python package

分類Dev

When to use IQueryable as Return type in web service

分類Dev

PHP Webサービス(SOAP)の保護

分類Dev

Secure Web Services: REST over HTTPS vs SOAP + WS-Security. Which is better?

分類Dev

Spring Web Service(SOAP)でのXSDの例外クラスの実装

分類Dev

Pass User info to WCF Web service with WCF method vs with Soap header

分類Dev

PHPからC#SOAP Webサービスを呼び出すと、不正なデータが生成されます

分類Dev

How to C# Soap Request Convert to PHP Code?

分類Dev

Convert C# soap client to PHP (issues in casting complex types)

分類Dev

PHPでxmlを送受信する方法(SOAP Webサービス)

分類Dev

SOAPを使用したPHPのWebサービス

分類Dev

SOAPとPHPを使用したWebサービスへの接続

分類Dev

Soap request authenticate php

分類Dev

SOAP WSDL php request

分類Dev

Parsing response from a HTTP web service (JSON) in PHP

分類Dev

Parsing response from a HTTP web service (JSON) in PHP

分類Dev

PHP output JSON Web Service charset UTF-8 error

分類Dev

Client part of the Digest Authentication using PHP POST to Web Service

分類Dev

php soap envelope namespace <soap:Envelope and <SOAP-ENV:Envelope

分類Dev

Visual Studio C#WebサービスSOAPコメント

分類Dev

使用带有XML数据的C Sharp Soap 1.1调用远程Web服务?如何

分類Dev

Difference between XML Over HTTP & SOAP Over HTTP

分類Dev

How to invoke a Web Service which requires a certificate in C#?

分類Dev

Removing xml namespaces in C# restful web service returned string

分類Dev

Consume a Web Service in C#: Remove Task.Wait()

Related 関連記事

  1. 1

    Securing a PHP Web service (SOAP)

  2. 2

    using javascript fetch API with a SOAP web service

  3. 3

    Java connect to SOAP web service using SSL handshake failure

  4. 4

    How can I use SOAP web service on REST App

  5. 5

    How to script SOAP based web service using SUDS python package

  6. 6

    When to use IQueryable as Return type in web service

  7. 7

    PHP Webサービス(SOAP)の保護

  8. 8

    Secure Web Services: REST over HTTPS vs SOAP + WS-Security. Which is better?

  9. 9

    Spring Web Service(SOAP)でのXSDの例外クラスの実装

  10. 10

    Pass User info to WCF Web service with WCF method vs with Soap header

  11. 11

    PHPからC#SOAP Webサービスを呼び出すと、不正なデータが生成されます

  12. 12

    How to C# Soap Request Convert to PHP Code?

  13. 13

    Convert C# soap client to PHP (issues in casting complex types)

  14. 14

    PHPでxmlを送受信する方法(SOAP Webサービス)

  15. 15

    SOAPを使用したPHPのWebサービス

  16. 16

    SOAPとPHPを使用したWebサービスへの接続

  17. 17

    Soap request authenticate php

  18. 18

    SOAP WSDL php request

  19. 19

    Parsing response from a HTTP web service (JSON) in PHP

  20. 20

    Parsing response from a HTTP web service (JSON) in PHP

  21. 21

    PHP output JSON Web Service charset UTF-8 error

  22. 22

    Client part of the Digest Authentication using PHP POST to Web Service

  23. 23

    php soap envelope namespace <soap:Envelope and <SOAP-ENV:Envelope

  24. 24

    Visual Studio C#WebサービスSOAPコメント

  25. 25

    使用带有XML数据的C Sharp Soap 1.1调用远程Web服务?如何

  26. 26

    Difference between XML Over HTTP & SOAP Over HTTP

  27. 27

    How to invoke a Web Service which requires a certificate in C#?

  28. 28

    Removing xml namespaces in C# restful web service returned string

  29. 29

    Consume a Web Service in C#: Remove Task.Wait()

ホットタグ

アーカイブ