使用PHP与.NET soap服务器连接时遇到一些问题。 我也在Google的StackOverflow上进行了一些搜索,但是找不到解决方案/相同的问题。

就是这个 我正在尝试从服务器获取一些数据。 请求进行得很好,但是响应似乎无效。

响应在此对象中仅包含一个对象元素“ any”。 显示原始xml / xsd数据。

我也尝试使用不同的方法(如simple_xml和domdocument)自己解析它,但是结果是“无效的数据/ xml”

有没有人遇到这个问题或有适当的解决方案?

您可以在下面找到请求的“结果转储”,如果需要更多数据,请询问。

干杯塞巴斯蒂安

GetArticleListResult Object
(
    [any] => <xs:schema xmlns:mstns="www.rentplus.be/webservices/ArticleList.xsd" xmlns="www.rentplus.be/webservices/ArticleList.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="dsArticleList" targetNamespace="www.rentplus.be/webservices/ArticleList.xsd" attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element name="dsArticleList" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="ArticleList"><xs:complexType><xs:sequence><xs:element name="Article_Key" type="xs:string" minOccurs="0"/><xs:element name="Warehouse_Number" type="xs:string" minOccurs="0"/><xs:element name="Date_Creation" type="xs:dateTime" minOccurs="0"/><xs:element name="Date_Last_Modification" type="xs:dateTime" minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><dsArticleList xmlns="www.rentplus.be/webservices/ArticleList.xsd"><ArticleList diffgr:id="ArticleList1" msdata:rowOrder="0" diffgr:hasChanges="inserted"><Article_Key>GELUM-LE400</Article_Key><Warehouse_Number>01</Warehouse_Number><Date_Creation>0001-01-01T00:00:00+01:00</Date_Creation><Date_Last_Modification>2011-08-10T00:00:00+02:00</Date_Last_Modification></ArticleList></dsArticleList></diffgr:diffgram>
)

===============>>#1 票数:1

我自己解决了这个问题。 我对XML和SOAP知之甚少,但是根据我所做的研究,默认的.net Web服务使名称空间和其他包装程序陷入混乱。 此外,php soap客户端会使情况变得更糟,并且无法创建适当的对象。 您得到的响应是1/2对象和1/2 XML。 没道理,对!

好吧,我加载对象的“ any”元素并将其加载到

$wsdl= {url of your WSDL}; //assuming its some WSDL generated by MS .net or visual studio.  Something a normal human WOULD NOT WRITE. 
$client = new SoapClient($wsdl);        //create a soap client and load WSDL
$result = $client->GetQuote($param);    //get result of the soap call
$quote = $result->GetQuoteResult;       //Get the response-- its an object.  this part is weird because it's an object containing xml parts.  There is no easy path to use it.

$xml_object = new SimpleXMLElement($quote->any);  //Grab the xml part and load as partial XML --> this took forever to figure out. anger here!!

foreach ($xml_object->Quote->Plans as $plan){       //here in my data, the XML becomes a standard ARRAY--> really getting mad now.
    //grab a few items out of the array for kicks.  Don't grab all of them, cuz some switch back to XML --> make up your mind.
    $item_names=array("QuoteID","ProductID","ProductName","PlanTypeID",
        "PlanName", "Deductible","Coinsurance", "CoverageAmount",
        "Duration", "FirstPayment", "RecurringPayment"  );
    foreach ($item_names as $item_name){
        print "$item_name=".$plan->$item_name.",  ";
    }
    print "\n";
}
print "</pre>";
</pre>

现在,您已经从Visual Studio .net Webserivce中检索了所需的信息。 容易吧!

===============>>#2 票数:-1

下面,我介绍如何处理SOAP请求和响应。 您将获得包含any包含您的数据的ObjectObject->any Object都将包含以下内容:

$WS_settings = array(
    'address' => 'http://example.com.asmx?wsdl',
    'username' => 'login',
    'password' => 'pass'
);
$WS_client = new SoapClient($WS_settings['address']);

$WS_params = new stdClass();
$WS_params->Username = $WS_settings['username'];
$WS_params->Password = $WS_settings['password'];

$WS_params->IdBrand = 1;
$WS_params->IdModel = 2;
$WS_params->IdApplication = 3;

$result = $WS_client->Get_Products($WS_params)->Get_ProductsResult->any;
var_dump($result);

  ask by Sebastiaan Blaas translate from so

未解决问题?本站智能推荐: