개발 중이며 WSDL, PlaceInvoiceFromStream에 정의 된 하나의 함수가있는 웹 서비스를 호출하려고합니다. 함수는 전달할 하나의 인수 인 Invoice를 정의합니다. XSD Shema에서 정의 된 WSDL 가져 오기 유형.PHP에서 원시 SoapClient를 사용하여 SOAP 호출을 수행하는 방법은 무엇입니까?
WSDL은 다음과 같습니다
<?xml version="1.0" encoding="utf-8"?>
<definitions name ="inService"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsdl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:tns="http://localhost/ebiz/ws/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://localhost/ebiz/ws/">
<import namespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
location="http://localhost/ebiz/ws/Invoice.xsd"
/>
<message name="getPlaceInvoiceInput">
<part name="body" element="xsdl:Invoice"/>
</message>
<message name="getPlaceInvoiceOutput">
<part name="body" type="xsd:string"/>
</message>
<portType name="inServicePortType">
<operation name="PlaceInvoiceFromStream">
<input message="tns:getPlaceInvoiceInput"/>
<output message="tns:getPlaceInvoiceOutput"/>
</operation>
</portType>
<binding name="inServiceBinding" type="tns:inServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="PlaceInvoiceFromStream">
<soap:operation soapAction="PlaceInvoiceFromStream"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="inService">
<port name="inServicePort" binding="tns:inServiceBinding">
<soap:address location="http://localhost/ebiz/ws/soapServer.php"/>
</port>
</service>
</definitions>
스키마는 다음과 같습니다
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:udt="urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.1">
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" schemaLocation="../common/UBL-CommonAggregateComponents-2.1.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" schemaLocation="../common/UBL-CommonBasicComponents-2.1.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2" schemaLocation="../common/UBL-UnqualifiedDataTypes-2.1.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" schemaLocation="../common/UBL-CommonExtensionComponents-2.1.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2" schemaLocation="../common/UBL-QualifiedDataTypes-2.1.xsd"/>
<xsd:element name="Invoice" type="InvoiceType"/>
<xsd:complexType name="InvoiceType">
<xsd:sequence>
<xsd:element ref="ext:UBLExtensions"/>
<xsd:element ref="cbc:UBLVersionID"/>
<xsd:element ref="cbc:CustomizationID" minOccurs="0"/>
<xsd:element ref="cbc:ProfileID" minOccurs="0"/>
<xsd:element ref="cbc:ID"></xsd:element>
<xsd:element ref="cbc:CopyIndicator" minOccurs="0"/>
<xsd:element ref="cbc:IssueDate"/>
<xsd:element ref="cbc:InvoiceTypeCode" minOccurs="0"/>
<xsd:element ref="cbc:Note" minOccurs="0"/>
<xsd:element ref="cbc:TaxPointDate" minOccurs="0"/>
<xsd:element ref="cbc:DocumentCurrencyCode" minOccurs="0"/>
<xsd:element ref="cbc:AccountingCost" minOccurs="0"/>
<xsd:element ref="cbc:LineCountNumeric" minOccurs="0"/>
<xsd:element ref="cac:InvoicePeriod" minOccurs="0"/>
<xsd:element ref="cac:OrderReference" minOccurs="0"/>
<xsd:element ref="cac:DespatchDocumentReference" minOccurs="0"/>
<xsd:element ref="cac:ReceiptDocumentReference" minOccurs="0"/>
<xsd:element ref="cac:ContractDocumentReference" minOccurs="0"/>
<xsd:element ref="cac:AdditionalDocumentReference" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="cac:Signature" minOccurs="0"/>
<xsd:element ref="cac:AccountingSupplierParty"/>
<xsd:element ref="cac:AccountingCustomerParty"/>
<xsd:element ref="cac:BuyerCustomerParty" minOccurs="0"/>
<xsd:element ref="cac:SellerSupplierParty" minOccurs="0"/>
<xsd:element ref="cac:TaxRepresentativeParty" minOccurs="0"/>
<xsd:element ref="cac:Delivery" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="cac:DeliveryTerms" minOccurs="0"/>
<xsd:element ref="cac:PaymentMeans" maxOccurs="unbounded"/>
<xsd:element ref="cac:PaymentTerms" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="cac:PrepaidPayment" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="cac:AllowanceCharge" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="cac:TaxTotal" maxOccurs="unbounded"/>
<xsd:element ref="cac:LegalMonetaryTotal"/>
<xsd:element ref="cac:InvoiceLine" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
UBL 2.1 스키마 : http://docs.oasis-open.org/ubl/prd2-UBL-2.1/UBL-2.1.html#SCHEMAS
송장은 XML 파일에 저장 복잡한 데이터입니다 , 네임 스페이스와 속성을 포함하고있다. 그것은 다음과 같이 시작합니다
<?xml version="1.0" encoding="UTF-8"?>
<Invoice
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2"
xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://localhost/ebiz/ws/Invoice.xsd"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2">
<ext:UBLExtensions>
<ext:UBLExtension>
<cbc:ID>INVOICE1</cbc:ID>
<cbc:Name>InvoiceIssuePlaceData</cbc:Name>
<ext:ExtensionAgencyURI>urn:invoice:issueplace</ext:ExtensionAgencyURI>
<ext:ExtensionContent>
<ext:InvoiceIssuePlace>MyCity</ext:InvoiceIssuePlace>
</ext:ExtensionContent>
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:ID>01 1206-2406-568</cbc:ID>`
등이 ...
나는이 방법을 시도 :
// LOAD XML and TRANSFORM FOR SoapClient
$xmlfile = "Invoice123.xml";
$xslfile = "xsltForSoapClientRequest.xsl";
$xmlDOM = new DOMDocument();
$xmlDOM->load($xmlfile);
$xslDOM = new DOMDocument();
$xslDOM->load($xslfile);
$proc = new XSLTProcessor;
$proc->importStyleSheet($xslDOM);
$transformedXML = $proc->transformToDoc($xmlDOM);
$xmldoc = simplexml_load_string($transformedXML);
// CREATE ARRAY
$xmlarr = xml2array($xmldoc->asXML());
$client = new SoapClient($wsdl,array('trace'=>1));
$result=$client->PlaceInvoiceFromStream($xmlarr);
하지만 성공.
XSL 변환 변경은 다음
- 속성 분리된다 :
- 노드 속성
- 복합 노드 값 "_"요소
xml2array 변경되어진다 노드 소자진다 배열
그래서, $ xmlarr은 웹 서비스 기능을 확인할 수 있습니다 다음과 같은 형태 :
array(2) {
["Invoice"]=>
array(15) {
["ext:UBLExtensions"]=>
array(1) {
["ext:UBLExtension"]=>
array(4) {
["cbc:ID"]=>
string(10) "INVOICE1"
["cbc:Name"]=>
string(21) "InvoiceIssuePlaceData"
["ext:ExtensionAgencyURI"]=>
string(25) "urn:invoice:issueplace"
["ext:ExtensionContent"]=>
array(1) {
["ext:InvoiceIssuePlace"]=>
string(7) "MyCity"
}
}
}
["cbc:UBLVersionID"]=>
string(3) "2.1"
["cbc:ID"]=>
string(16) "01 1206-2406-568"
...
["Invoice_attr"]=>
array(8) {
["xmlns"]=>
string(54) "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
["xmlns:xsi"]=>
string(41) "http://www.w3.org/2001/XMLSchema-instance"
["xmlns:cac"]=>
string(72) "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
["xmlns:cbc"]=>
string(68) "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
["xmlns:sac"]=>
string(75) "urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2"
["xmlns:ext"]=>
string(72) "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
["xmlns:sig"]=>
string(72) "urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2"
["xsi:schemaLocation"]=>
string(93) "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://localhost/ebiz/ws/Invoice.xsd"
}
}
웹 서비스 호출의 결과는 다음과 같습니다
SOAP-ERROR: Encoding: object has no 'UBLExtensions' property
은 무엇에 대한 형태이어야한다 정확한 SOAP 요청? SOAP 요청에 어떤 형태의 배열이 필요합니까? SOAP은 WSDL 및 XSD를 기반으로 "_"요소를 인식합니까? 또는 별도의 배열에 특성? 이 문제를 해결에 어떤 도움에 미리
감사합니다 ...
UPDATE :
변경된 WSDL :
<message name="getPlaceInvoiceInput">
<part name="Invoice" element="xsdl:InvoiceType"/>
SoapClient 요청 다음 허용합니다
$xmlarr = array(
"UBLExtensions"=>
array(
"UBLExtension"=>
array(
"ID"=>"INVOICE1",
"Name"=>"InvoiceIssuePlaceData",
"ExtensionAgencyURI"=>"urn:invoice:issueplace",
"ExtensionContent"=>
array(
"InvoiceIssuePlace"=>"MyCity"
)
)
),
"UBLVersionID"=>"2.1",
"ID"=>"01 1206-2406-568",
...
하는 내가 원하는 것이 아니다. 열쇠에 네임 스페이스가 필요합니다. SoapClient가 요청 배열 (예 : "ext : UBLExtensions")의 키 내에 네임 스페이스를 허용 할 수있게하려면 변경/추가해야하는 것은 무엇입니까?
WSDL 및 스키마를 추가 할 수 있습니까? 아마도 샘플 XML 메시지보다 더 유용 할 것입니다. – davidfmatheson
WSDL 및 스키마가 추가되었습니다 ... –