donglieshe4692 2018-06-20 06:45
浏览 74
已采纳

在PHP中等效的C#Web服务代码(将auth数据作为标头发送)

We are trying to use a web service (SoapClient) in a PHP project to send SMS. The web service is created with C# (dot net framework). The project manager described that the authentication data have to be sent using headers not as arguments in method (like most web services).

Here is the sample code they gave us:

using (var sms = new sms.Service()) 
{
    var auth = new sms.AuthHeader();

    auth.Username = "SERVICE_USERNAME";
    auth.Password = "SERVICE_PASSWORD";
    sms.AuthHeaderValue = auth;

    return sms.SendSms(messagesArray, phoneNumbersArray);            
}

The web service address is:

http://192.168.10.10/Service.asmx?WSDL

I would appreciate if anyone can suggest an equivalent for this code in PHP?

  • 写回答

1条回答 默认 最新

  • dtd5644 2018-06-20 06:49
    关注

    http://php.net/manual/de/class.soapheader.php

    SoapHeader {
    /* Methoden */
        __construct ( string $namespace , string $name [, mixed $data [, bool $mustunderstand [, string $actor ]]] )
        SoapHeader ( string $namespace , string $name [, mixed $data [, bool $mustunderstand = FALSE [, string $actor ]]] )
    }
    

    Here is an example too: How to set this php soap header?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题