帮忙将下面C#的代码转换成PHP的代码,谢谢!
<client>
            <endpoint address="http:///sysNotifyTodoWebService"
                binding="basicHttpBinding" bindingConfiguration="ISysNotifyTodoWebServiceServiceSoapBinding"
                contract="OAService.ISysNotifyTodoWebService" name="ISysNotifyTodoWebServicePort">
               <headers>
                <RequestSOAPHeader xmlns:tns="testaa">
                    <tns:password>123</tns:password>
                    <tns:user>admin</tns:user>
                </RequestSOAPHeader>
              </headers>
              
            </endpoint>
        </client>

解决方案 »

  1.   

    这仅仅是一个xml格式的代码,不是C#代码,无需转PHP。
    PHP可以直接使用这个代码
      

  2.   

    PHP有读取xml的方法。具体你可以下载PHP manual看看。
      

  3.   


    $Data = " <client>
                <endpoint address="http:///sysNotifyTodoWebService"
                    binding="basicHttpBinding" bindingConfiguration="ISysNotifyTodoWebServiceServiceSoapBinding"
                    contract="OAService.ISysNotifyTodoWebService" name="ISysNotifyTodoWebServicePort">
                   <headers>
                    <RequestSOAPHeader xmlns:tns="testaa">
                        <tns:password>123</tns:password>
                        <tns:user>admin</tns:user>
                    </RequestSOAPHeader>
                  </headers>
                  
                </endpoint>
            </client>";
    $Xml = simplexml_load_string($Data);子节点$client = $Xml->client;
    $endpoint = $client->endpoint;属性值
    foreach($endpoint->attributes() as $a => $b)
    {
         echo $a,'="',$b,"\"<br>";
    }
      

  4.   


    http:///sysNotifyTodoWebService中有个接口函数sendTodo(),如果调用?,为什么我这样调用后提示Call to a member function sendTodo() on a non-object 
    $client = $Xml->client;
    $endpoint = $client->sendTodo($post_data);
      

  5.   

    sendTodo()是接口里的函数   不是在$client里 
    $client->sendTodo 这样是在调$client里的sendTodo函数 那当然没有啊不清楚你那边是要做什么 看起来不是xml的读写  这里面没有哪里需要涉及到c#吧 
    即使是调的接口是.Net的WebService的,对php而言读取方法都是一样的我猜一下,你这边是php 接口提供方是c#  你是不是要调接口读取了xml后修改节点内容  然后用接口提供的函数再POST提交?
      

  6.   


    情况是这样的,我做了个小软件,需要给公司的OA系统发送待办,公司里的人给了我“http:///sysNotifyTodoWebService?wsdl”,连接时,需要用帐号密码认证后才调用接口函数sendTodo()。但我现在是不懂如何去用帐号密码认证,及后续如何调用接口函数sendTodo()。首层里的那些代码是我用C#连接wsdl时,认证的一段代码。我想问的是有没有别的办法或用上面代码实现我的目地。能否帮忙解决,谢谢!
      

  7.   

    $p = array(
      'uri' => 'http://sysNotifyTodoWebService',
      'location' => 'http://sysNotifyTodoWebService?wsdl',
      'trace' => true,
      'soap_version' => SOAP_1_2,
    );$c = new SoapClient(null, $p);
    $a = ['testaa' =>[ 'password' => 123, 'user' => 'admin']];
    $h = new SoapHeader ( $p['uri'], 'testaa', $a,
         true, SOAP_ACTOR_NEXT );
    $c->__setSoapHeaders ( array ($h ) );但你给的身份信息对吗?
      

  8.   


    我照你的做了,结果报这个错,是哪里有问题啊
    34:  $post_data=array('appName'=> 'QIF','modelName'=> 'QIF','modelId'=> 'QIF1234567989','subject'=> '请处理QIF单新流程测试','link'=> 1,'createTime'=> '2018-1-15 0   0:00:00','targets' =>array('LoginName' =>'lizz'));
    35:  $endpoint = $c->sendTodo(array($post_data));Fatal error: Uncaught SoapFault exception: [HTTP] Internal Server Error in D:\PHPnow\htdocs\QIF201708\cysl\newsendoatest1.php:35 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://oa.haima...', 'http://oa.haima...', 2, 0) #1 D:\PHPnow\htdocs\QIF201708\cysl\newsendoatest1.php(35): SoapClient->__call('sendTodo', Array) #2 D:\PHPnow\htdocs\QIF201708\cysl\newsendoatest1.php(35): SoapClient->sendTodo(Array) #3 {main} thrown in D:\PHPnow\htdocs\QIF201708\cysl\newsendoatest1.php on line 35
      

  9.   

    这种事情只有你自己解决
    1、没有给出正确的用户名和口令
    2、给出的 url 不是公网的