2011-12-25 2 views
0

SOAP 클라이언트를 얻으려고하고 있습니다. 서비스 제공 업체에서 얻은 유일한 예는 Java이지만, PHP로해야합니다. 나는 젠드 (Zend)에 새로 온 것이 아니지만 SOAP를 처음 사용하는 사람이다.PHP를 사용하여 CXF 서비스에 대한 보안 연결을 만드는 방법은 무엇입니까?

호스트 서비스가 Apache CXF를 사용하고 있다고 생각합니다.

I (아래)이처럼 사용하고 점점 유지하고 예외 내가 얻고

$wsdlprice = '/home/rob/var/www/catalog-pim/public/wsdl-docs/PriceAvailabilityService_V02.wsdl'; 
$client = new Zend_Soap_Client($wsdlprice, array('encoding' => 'UTF-8', 'compression' => SOAP_COMPRESSION_ACCEPT)); 
$client->setOptions(array('login' => 'my-username', 'password' => 'my-password')); 

    print_r($client); 

try { 
    $client->getPriceAvailability(array('hideZeroInv' => '0')); 
} 
catch (SoapFault $exception) { 
    echo '<br /><br /><br />EXCEPTION=' . $exception; 
} 

오류 '사용자 이름은 제공되지'오전 :

EXCEPTION=SoapFault exception: [soap:000101] Username is not provided in /home/rob/var/www/catalog-pim/library/Zend/Soap/Client.php:1121 Stack trace: #0 /home/rob/var/www/catalog-pim/library/Zend/Soap/Client.php(1121): SoapClient->__soapCall('getPriceAvailab...', Array, NULL, NULL, Array) 

내가 젠드의에서보고했다을 1121 줄의 'Client.php'그리고 그것은 비누 '__call'메소드입니다. PHP의 비누가 싫어하는 것일 수도 있습니다. '사용자 이름'을 가지고 있지 않은 것 같아요.

$ client에 'username'또는 'Username'을 계속 추가하려고 시도하고 있습니다. 그것은 'getPriceAvailability()'메소드입니다. 나는 그것을 요청 헤더에 넣어야한다고 생각하지만, 그 중 하나를 이해할 수 없다. 나는 $client->addSoapInputHeader(new SoapHeader::$header);으로 덤비는 것을 시도했다. 그러나 나는 $ header에 무엇을 넣을 지 모른다. 그리고 나는 웹에서 많은 것을 찾지 못한다.

의 WSDL 문서 :

<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="PriceAvailabilityServiceV02" targetNamespace="http://pnaV02.model.ws.synnex.com/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://pnaV02.model.ws.synnex.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UTOverTransport"> 
     <wsp:ExactlyOne> 
      <wsp:All> 
       <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
        <wsp:Policy> 
         <sp:TransportToken> 
          <wsp:Policy> 
            <sp:HttpsToken RequireClientCertificate="false"/> 
          </wsp:Policy> 
         </sp:TransportToken> 
         <sp:AlgorithmSuite> 
          <wsp:Policy> 
           <sp:Basic256/> 
          </wsp:Policy> 
         </sp:AlgorithmSuite> 
         <sp:Layout> 
          <wsp:Policy> 
           <sp:Lax/> 
          </wsp:Policy> 
         </sp:Layout> 
         <sp:IncludeTimestamp/> 
        </wsp:Policy> 
       </sp:TransportBinding> 
       <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
        <wsp:Policy> 
         <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"/> 
        </wsp:Policy> 
       </sp:SignedSupportingTokens> 
      </wsp:All> 
     </wsp:ExactlyOne> 
    </wsp:Policy>  
    <wsdl:types> 
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://pnaV02.model.ws.synnex.com/" xmlns:tns="http://pnaV02.model.ws.synnex.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="getPriceAvailability" type="tns:getPriceAvailability" /> 
    <xs:element name="getPriceAvailabilityResponse" type="tns:getPriceAvailabilityResponse" /> 
    <xs:complexType name="getPriceAvailability"> 
     <xs:sequence> 
      <xs:element maxOccurs="unbounded" minOccurs="0" name="skuList" type="tns:skuList" /> 
      <xs:element maxOccurs="unbounded" minOccurs="0" name="warehouse" type="tns:warehouse" /> 
      <xs:element name="hideZeroInv" type="xs:boolean" /> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="skuList"> 
     <xs:sequence> 
      <xs:element minOccurs="0" name="synnexSku" type="xs:int" /> 
      <xs:element minOccurs="0" name="specialPriceType" type="tns:specialPriceType" /> 
      <xs:element minOccurs="0" name="mfgPartNumber" type="xs:string" /> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="getPriceAvailabilityResponse"> 
     <xs:sequence> 
      <xs:element minOccurs="0" name="return" type="tns:pnaResponse" /> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="pnaResponse"> 
     <xs:sequence> 
      <xs:element maxOccurs="unbounded" name="priceAvailabilityList" type="tns:pnaDetail" /> 
      <xs:element name="errorMessage" type="xs:string" /> 
      <xs:element name="errorDetail" type="xs:string" /> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="pnaDetail"> 
     <xs:sequence> 
      <xs:element name="synnexSku" type="xs:int" /> 
      <xs:element name="mfgPartNumber" type="xs:string" /> 
      <xs:element name="mfgCode" type="xs:int" /> 
      <xs:element name="status" type="tns:pnaPartStatus" /> 
      <xs:element name="shortDescription" type="xs:string" /> 
      <xs:element name="globalProductStatusCode" type="tns:pnaPartStatus" /> 
      <xs:element name="resellerPrice" type="xs:double" /> 
      <xs:element name="totalQuantity" type="xs:int" /> 
      <xs:element name="totalOnOrder" type="xs:int" /> 
      <xs:element name="totalBO" type="xs:int" /> 
      <xs:element maxOccurs="unbounded" name="availabilityByWarehouseList" type="tns:availabilityByWarehouse" /> 
      <xs:element name="lineNumber" type="xs:int" /> 
      <xs:element minOccurs="0" name="specialPriceType" type="tns:specialPriceType" /> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="availabilityByWarehouse"> 
     <xs:sequence> 
      <xs:element name="warehouseInfo" type="tns:warehouseInfo" /> 
      <xs:element name="quantity" type="xs:int" /> 
      <xs:element maxOccurs="unbounded" minOccurs="0" name="ETAList" type="tns:availETA" /> 
      <xs:element name="OnOrder" type="xs:int" /> 
      <xs:element name="BO" type="xs:int" /> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="warehouseInfo"> 
     <xs:sequence> 
      <xs:element name="warehouse" type="tns:warehouse" /> 
      <xs:element name="zipCode" type="xs:string" /> 
      <xs:element name="city" type="xs:string" /> 
      <xs:element name="address" type="xs:string" /> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:complexType name="availETA"> 
     <xs:sequence> 
      <xs:element minOccurs="0" name="ETA" type="xs:string" /> 
      <xs:element name="QTY" type="xs:int" /> 
     </xs:sequence> 
    </xs:complexType> 
    <xs:simpleType name="specialPriceType"> 
     <xs:restriction base="xs:string"> 
      <xs:enumeration value="PROMOTION" /> 
      <xs:enumeration value="FEDERALGOVERNMENT" /> 
      <xs:enumeration value="STATEGOVERNMENT" /> 
      <xs:enumeration value="EDUCATION" /> 
     </xs:restriction> 
    </xs:simpleType> 
    <xs:simpleType name="warehouse"> 
     <xs:restriction base="xs:string"> 
      <xs:enumeration value="ANY" /> 
      <xs:enumeration value="CLOSEST" /> 
      <xs:enumeration value="MULTIPLE" /> 
      <xs:enumeration value="DNV" /> 
      <xs:enumeration value="DFR" /> 
      <xs:enumeration value="DAT" /> 
      <xs:enumeration value="DTX" /> 
      <xs:enumeration value="DCH" /> 
      <xs:enumeration value="DTN" /> 
      <xs:enumeration value="DNJ" /> 
      <xs:enumeration value="DDC" /> 
      <xs:enumeration value="DOR" /> 
      <xs:enumeration value="DLA" /> 
      <xs:enumeration value="DCC" /> 
      <xs:enumeration value="DOH" /> 
      <xs:enumeration value="DFL" /> 
      <xs:enumeration value="DDS" /> 
      <xs:enumeration value="UNKNOWN" /> 
      </xs:restriction> 
    </xs:simpleType> 
    <xs:simpleType name="pnaPartStatus"> 
     <xs:restriction base="xs:string"> 
      <xs:enumeration value="DISCONTINUED" /> 
      <xs:enumeration value="INACTIVE" /> 
      <xs:enumeration value="ACTIVE" /> 
      <xs:enumeration value="NOTAUTHORIZED" /> 
      <xs:enumeration value="NOTSETUP" /> 
      <xs:enumeration value="NOTFOUND" /> 
      <xs:enumeration value="UNKNOWN" /> 
     </xs:restriction> 
    </xs:simpleType> 
</xs:schema> 
    </wsdl:types> 
    <wsdl:message name="getPriceAvailability"> 
    <wsdl:part element="tns:getPriceAvailability" name="parameters"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:message name="getPriceAvailabilityResponse"> 
    <wsdl:part element="tns:getPriceAvailabilityResponse" name="parameters"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:portType name="PriceAvailabilityService" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" wsp:PolicyURIs="#UTOverTransport"> 
    <wsdl:operation name="getPriceAvailability"> 
     <wsdl:input message="tns:getPriceAvailability" name="getPriceAvailability"> 
    </wsdl:input> 
     <wsdl:output message="tns:getPriceAvailabilityResponse" name="getPriceAvailabilityResponse"> 
    </wsdl:output> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="PriceAvailabilityServiceV02SoapBinding" type="tns:PriceAvailabilityService"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="getPriceAvailability"> 
     <soap:operation soapAction="" style="document" /> 
     <wsdl:input name="getPriceAvailability"> 
     <soap:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output name="getPriceAvailabilityResponse"> 
     <soap:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="PriceAvailabilityServiceV02"> 
    <wsdl:port binding="tns:PriceAvailabilityServiceV02SoapBinding" name="PriceAvailabilityServicePort"> 
     <soap:address location="http://ws.synnex.com/webservice/pnaserviceV02" /> 
    </wsdl:port> 
    <wsdl:port binding="tns:PriceAvailabilityServiceV02SoapBinding" name="PriceAvailabilityServicePort_UAT"> 
     <soap:address location="http://testws.synnex.com/webservice/pnaserviceV02" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

답변

0

... 다시는 내 자신의 질문에 대답 (그렇게 나쁘지 아니지만)

나는 내가 CXF 서비스 http://cxf.apache.org/

에 연결을 시도 사실 나는 것을 발견

이 특정 서비스는 여기에 설명 된 WS 보안을 사용합니다. http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss

나는이 문제를 atte 다행스럽게도 PHP를 사용하여 이러한 서비스에 연결하는 mpting이 게시물을 찾았습니다. http://sastriawan.blogspot.com/2010/01/accessing-ws-security-protected.html

위의 링크는 University of Tornto 웹 사이트에서 얻은 클래스 사용 방법의 예제와 명확한 'xmlseclibs'구글 코드에서 찾았습니다 http://code.google.com/p/xmlseclibs/

아직 '새로운'코드를 광범위하게 연구하지는 않았지만 요청 헤더에 인증을 처리하는 것으로 보입니다. .

SoapClient를 확장하고 내 자격 증명을 추가하고 이제 서버에 연결할 수있는 블로그의 새로운 클래스를 만들었습니다 ... 메서드 변수가 누락되었다는 불만을 받고 ... 나는 곧 연결할 수 있다고 고쳐 쓴다.

관련 문제