donglianjiang9321 2014-04-16 22:37 采纳率: 0%
浏览 28

PHP:使用带标记的CURL发送xml

I need send a xml file using curl, but the HEADER of the xml have a tag on Header. see the xml below:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.adform.com/api/2010/06"
xmlns:ns1="http://www.adform.com/api/2013/06/18"
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
   <soapenv:Header>
      <ns:Ticket>Dz02gYmsWnlWF1-hNCVC58jP7QF0idTYi9r9VkjOCIMzpwQ63uZiK4N46NsGs4gX7dryU5nt-FMqRbfs-x2WPg__</ns:Ticket>
   </soapenv:Header>
   <soapenv:Body>
      <ns1:CreateReportScheduleData>
         <ns1:ReportSchedule>
            <ns1:TemplateId>42734</ns1:TemplateId>
            <ns1:Name>ReportScheduleName</ns1:Name>
            <ns1:StartDate>2013-06-18T00:00:00</ns1:StartDate>
            <ns1:EndDate>2013-06-22T00:00:00</ns1:EndDate>
            <ns1:FileDelivery xsi:type="ns1:FileDeliveryToFtp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <ns1:FtpAddress>ftp://ftp.mycompany.com</ns1:FtpAddress>
               <ns1:UserName>username</ns1:UserName>
               <ns1:NotificationEmail>notifications@mycompany.com</ns1:NotificationEmail>
               <ns1:Password>password</ns1:Password>
            </ns1:FileDelivery>
            <ns1:Frequency>Weekly</ns1:Frequency>
            <ns1:WeekDays>
               <ns1:WeekDay>Monday</ns1:WeekDay>
               <ns1:WeekDay>Wednesday</ns1:WeekDay>
            </ns1:WeekDays>
            <ns1:FileFormat>Csv</ns1:FileFormat>
            <ns1:DataFilters>
               <ns1:ReportPresetInterval>Custom</ns1:ReportPresetInterval>
               <ns1:ReportInterval>
                  <ns1:StartDate>2013-06-04T00:00:00</ns1:StartDate>
                  <ns1:EndDate>2013-06-16T00:00:00</ns1:EndDate>
               </ns1:ReportInterval>
               <ns1:AdvertiserIds>
                  <arr:int>2544</arr:int>
               </ns1:AdvertiserIds>
               <ns1:CampaignIds>
                  <arr:int>22742</arr:int>
               </ns1:CampaignIds>
               <ns1:MediaIds>
                  <arr:int>65335</arr:int>
                  <arr:int>65337</arr:int>
               </ns1:MediaIds>
               <ns1:TrackingPointFilterId>18077</ns1:TrackingPointFilterId>
            </ns1:DataFilters>
         </ns1:ReportSchedule>
      </ns1:CreateReportScheduleData>
   </soapenv:Body>
</soapenv:Envelope>

This is an example of the soap request, anyone have some ideia how i can set the Ticket tag with CURL?

Thanks a lot!

  • 写回答

1条回答 默认 最新

  • douxing8855 2014-04-16 23:47
    关注

    You could use a regular expression, or :

    <?php
    
    $xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/.........';
    
    list($part1, $part2) = explode("<ns:Ticket>", $xml);
    
    list($ticket, $part3) = explode("</ns:Ticket>", $part2);
    
    $newTicket = "<ns:Ticket>blablabla</ns:Ticket>"; // <== your ticket here
    
    $xml = $part1 . $newTicket . $part3;
    
    echo $xml;
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程