2011-08-08 2 views
0

세일즈 포스를 처음 사용했습니다. PHP에 능숙하지만 어떤 xml 파싱도하지 않았습니다. 나는이 파일을 가지고있다. 세일즈 포스의 객체가 변경 될 때 작성됩니다 : 나는 SF 네임 스페이스의 값을 가지고 데이터베이스를 업데이트 할 수 있도록PHP의 salesforce에서 네임 스페이스로 SOAP 메시지를 소비하는 방법

<?xml version="1.0" encoding="UTF-8"?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<soapenv:Body> 
<notifications xmlns="http://soap.sforce.com/2005/09/outbound"> 
    <OrganizationId>00D30000000opwSEAQ</OrganizationId> 
    <ActionId>04k30000000L6QPAA0</ActionId> 
    <SessionId xsi:nil="true"/> 
    <EnterpriseUrl>https://na1-api.salesforce.com/services/Soap/c/22.0/00D30000000opwS</EnterpriseUrl> 
    <PartnerUrl>https://na1-api.salesforce.com/services/Soap/u/22.0/00D30000000opwS</PartnerUrl> 
    <Notification> 
    <Id>04l3000000JbKClAAN</Id> 
    <sObject xsi:type="sf:Account" xmlns:sf="urn:sobject.enterprise.soap.sforce.com"> 
    <sf:Id>0013000000ooziWAAQ</sf:Id> 
    <sf:BillingCity>New York</sf:BillingCity> 
    <sf:BillingCountry>US</sf:BillingCountry> 
    <sf:BillingPostalCode>10000</sf:BillingPostalCode> 
    <sf:BillingState>New York</sf:BillingState> 
    <sf:BillingStreet>302 E xxx St Apt C</sf:BillingStreet> 
    <sf:FN__Mapping_Status__c>Not Located Yet</sf:FN__Mapping_Status__c> 
    <sf:IsDeleted>false</sf:IsDeleted> 
    <sf:Member_Status__c>Active</sf:Member_Status__c> 
    <sf:Name>Joel Test</sf:Name> 
    </sObject> 
    </Notification> 
</notifications> 
</soapenv:Body> 
</soapenv:Envelope> 

나는 그것을 구문 분석 할 필요가있다. SimpleXML을 사용하여 네임 스페이스의 항목을 읽을 수는 있지만 네임 스페이스 값을 읽을 수는 없습니다. 누군가가 이것을 수행하는 방법에 대한 예제 코드 나 튜토리얼을 가르쳐 줄 수 있습니까?

답변

0

Salesforce의 아웃 바운드 메시징 기능에서 보낸 SOAP 메시지 인 것 같습니다. XML로만 처리하는 대신 Salesforce에서 제공하는 WSDL과 함께 PHP SoapServer 네이티브를 사용하십시오. 이렇게하면 SOAP 메시지를 처리하도록 설계되었습니다. WSDL은 Setup | 만들기 | 워크 플로우 & 승인 | 아웃 바운드 메시지 | | 엔드 포인트 WSDL. 해당 PHP SoapClient를 사용하고 sf : namespace를 처리하고 SObject 객체로 변환하는 유틸리티가있는 Salesforce PHP Client을 살펴볼 수도 있습니다. 아웃 바운드 메시지를 처리 ​​할 수 ​​있도록 클라이언트가 아닌 서버로 작동하도록 툴킷을 다시 연결하는 것이 너무 어렵지 않아야합니다.

0

PHP의 SimpleXML이이 케이스에서 작동 할 수 있습니다. children()을 사용하고 올바른 구문을 사용해야합니다. 따라서

는, 당신은 다음 코드를 사용할 수 있습니다 세일즈 포스 아웃 바운드 메시지의 필드 값 BillingCity을 읽을 수 있습니다 :

$rcXML->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://soap.sforce.com/2005/09/outbound')->notifications->Notification->sObject->children('urn:sobject.enterprise.soap.sforce.com')->BillingCity 

것은 당신이, 내가 SAMES 코드 및 XML과 게시물을 작성 어떻게 작동하는지 이해하는 데 도움이되어야한다있는 이해하기 쉽다. 당신이 제출 한 값을 읽을 수 있습니다되면

http://amigotechnotes.wordpress.com/2013/11/16/parse-xml-with-namespace-by-simplexml-in-php/

, 당신은 PHP와 다른 데이터베이스 또는 텍스트 파일로 저장할 수 있습니다.

관련 문제