无法在PHP

时间:2018-03-09 21:30:41

标签: php html5 rest soap

我正在将目录功能集成到我设计的公司网站akserigraphics.com。我已经使用REST集成了所有drinkware项目和许多促销项目。现在我正在尝试集成garments,但它们来自使用SOAP的不同来源。我可以成功地调用SOAP并在SoapUI中检查它,但是我无法访问PHP文档中对象的内容。

以下是我试图在PHP中填充SOAP数据的布局:

<?php
foreach ($result -> listResponse as $item): ?>
  <a href="/products/garments/brands/new.era/productview.php?model=<?php echo $item->style; ?>">
    <div id="shirt_<?php print $item->style; ?>'" class="catalog-box-1 three-col-por">
      <div class="catalog-box-1-content">
        <div class="mask"></div>
        <h3><span><?php print $item->style; ?></span><br><?php print $item->productTitle; ?></h3>
        <?php $thumbpic = $item->productImage; ?>
        <img src="<?php print $thumbpic; ?>" alt="<?php print $item->productTitle; ?>">
      </div>
    </div>
  </a>
  <?php endforeach; ?>

以下是我正在使用的代码:

<?php
$actualLink = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$perPage = isset($_GET['per-page']) && $_GET['per-page'] <= 48 ? (int)$_GET['per-page'] : 12;
$previous = $page - 1;
$next = $page + 1;
$start = ($page > 1) ? ($page * $perPage) - $perPage : 0;
$a = $page - 2;
$b = $page - 1;
$e = $page;
$c = $page + 1;
$d = $page + 2;

$findBrand = 'New Era';

try{
    ini_set('max_execution_time', 900); 

    $localhostWsdlUrl="https://stage-ws.sanmar.com:8080/SanMarWebService/SanMarProductInfoServicePort?WSDL";

    $client= new SoapClient($localhostWsdlUrl, array('trace'=>true, 'exceptions'=>true));

    //these methods used to see the wsdl methods and their types.
    //var_dump($client->__getFunctions() ); 
    //var_dump('<br/>');  
    //var_dump($client->__getTypes());

    //web service credentail 
    $arg0 = array('brandName' => $findBrand);

    $arg1 = array(
                'sanMarCustomerNumber' => '1175',
                'sanMarUserName' => '######',
                'sanMarUserPassword' => '######'
            );

    $getProductInfoByBrand = array('arg0' => $arg0, 'arg1' => $arg1 );

    //calling the GetInvoiceByInvoiceNo method.
    $result = $client->__soapCall('getProductInfoByBrand', array('getProductInfoByBrand' => $getProductInfoByBrand));
    //var_dump($result);

} catch(SoapFault $e) {
  //var_dump($e);
}

?>

以下是我收到的输出:

  

警告:第246行/home/akswebmaster/akserigraphics.com/products/garments/brands/new.era/index.php中为foreach()提供的参数无效

运行var_dump($ results);产生以下内容:

  

object(stdClass)#2(1){[&#34; return&#34;] =&gt; object(stdClass)#3(2){[&#34; errorOccured&#34;] =&gt; bool(true)[&#34; message&#34;] =&gt; string(34)&#34; ERROR:用户身份验证失败。&#34; }}

这是SoapUI返回的内容:

&#13;
&#13;
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
    <ns2:getProductInfoByBrandResponse xmlns:ns2="http://impl.webservice.integration.sanmar.com/">
      <return>
        <errorOccured>false</errorOccured>
        <listResponse>
          <productBasicInfo>
            <brandName>OGIO Endurance</brandName>
            <caseSize>8</caseSize>
            <catalogColor>Cobalt</catalogColor>
            <color>Black/Silver/Cobalt</color>
            <inventoryKey>70172</inventoryKey>
            <keywords>ogio, duffel, multi-sport duffel, duffel bag, sports duffel, sports bag, shoe compartment, shoe pocket, shoe-pocket, shoe-compartment,ventilated shoe compartment, adjustable shoulder strap, side pocket, sweat-resistant carrying handle, accessory
              pocket, high visibility liner, high visibility,</keywords>
            <pieceWeight>1.6458</pieceWeight>
            <productDescription>Unleash the adrenaline inside you with this intuitively designed multi-sport duffel. 420D diamond rip stop/300D poly diamond rip stop/600D poly Large main compartment Ventilated shoe compartment Secondary zippered side pocket Adjustable shoulder
              strap with ventilated shoulder pad Sweat-resistant soft touch molded carrying handle Zippered front accessory pocket Durable, abrasion-resistant base Dimensions: 10.5"h x 20"w x 9.25"d Capacity: 2,500 cu. in./41L Weight 1.2 lbs./0.5kg Bags
              not intended for use by children 12 and under.</productDescription>
            <productStatus>CloseOut</productStatus>
            <productTitle>CLOSEOUT OGIO ENDURANCE - 2.0 Duffel 412030</productTitle>
            <size>OSFA</size>
            <sizeIndex>3</sizeIndex>
            <style>
              412030
            </style>
            <uniqueKey>701723</uniqueKey>
          </productBasicInfo>
          <productImageInfo>
            <brandLogoImage>https://cdnl.sanmar.com/catalog/images/ogioenduranceheader.jpg</brandLogoImage>
            <colorProductImage>https://cdnl.sanmar.com/catalog/images/imglib/catl/2012/f12/412030_BlackSilverCobalt_Flat_GA13.jpg</colorProductImage>
            <colorProductImageThumbnail>https://cdnl.sanmar.com/cache/altview/imglib/catl/2012/f12/412030_BlackSilverCobalt_Flat_GA13.jpg</colorProductImageThumbnail>
            <colorSquareImage>https://cdnl.sanmar.com/swatch/gifs/ogio_blueprint.gif</colorSquareImage>
            <colorSwatchImage>https://cdnl.sanmar.com/catalog/images/412030sw.jpg</colorSwatchImage>
            <productImage>https://cdnl.sanmar.com/catalog/images/412030.jpg</productImage>
            <specSheet>https://www.apparelvideos.com/images/specsheet/pdf/specsheet/412030_specsheet.pdf</specSheet>
            <thumbnailImage>https://cdnl.sanmar.com/catalog/images/412030TN.jpg</thumbnailImage>
            <titleImage/>
            <frontModel>https://cdnl.sanmar.com/imglib/mresjpg/2012/f12/412030_BlackSilverCobalt_Flat_GA13.jpg</frontModel>
            <backModel/>
            <sideModel/>
            <backFlat/>
            <frontFlat/>
            <threeQModel/>
          </productImageInfo>
          <productPriceInfo>
            <casePrice>24.6</casePrice>
            <caseSalePrice>12.28</caseSalePrice>
            <dozenPrice>26.6</dozenPrice>
            <dozenSalePrice>12.28</dozenSalePrice>
            <piecePrice>28.6</piecePrice>
            <pieceSalePrice>12.28</pieceSalePrice>
            <priceCode>R</priceCode>
            <priceText>OSFA</priceText>
            <saleEndDate>2020-06-29</saleEndDate>
            <saleStartDate>2016-07-23</saleStartDate>
          </productPriceInfo>
        </listResponse>
&#13;
&#13;
&#13;

我一直在寻找好几天,似乎无法确定我做错了什么。我还联系了整合支持&#39;在SOAP调用来自并得到以下响应的公司

  

不幸的是,我不知道你需要做什么,我们不做任何编码。

对于PHP来说,我只是一个初学者,所以任何帮助都会非常感激。

1 个答案:

答案 0 :(得分:0)

显然有两个问题。第一个问题是我使用的WSDL是测试版,而不是生产版。

https://stage-ws.sanmar.com:8080/SanMarWebService/SanMarProductInfoServicePort?WSDL

应该是

https://ws.sanmar.com:8080/SanMarWebService/SanMarProductInfoServicePort?WSDL

修复后我面临服务器超时的新问题。经过几周的挫折和数百种变化后,我能够从供应商处获得一位知识渊博的IT人员。事实证明,我的调用返回了太多数据,导致连接超时。他的解决方案是让我下载所有产品的csv文件并将其加载到我的服务器上的数据库中,然后我可以从中运行SQL命令。我将在下周这样做,最终可以完成这个项目。