I'm using PHP Soap Client with WSDL to send soap requests. That's the way I initialize the SoapClient:
$options = [ "trace" => 1, "login" => "Universal API/uAPI3170205802-sdv3r34", "password" => "U^#3@$dfw2", "classmap" => [ "BookingDisplayRsp" => "BookingAirSegmentRsp" ], ]; $this->soapClient = new \SoapClient("BookingAirPnrElement.wsdl",$options); $request = [ "BookingAirPnrElementReq" => [ "AuthorizedBy" => 'user', "SessionKey" => 'e6a30377-0956-4ac4-947d-b4ccb6641629', "BillingPointOfSaleInfo" => [ "OriginApplication" => "uAPI" ], "AddAirPnrElement" => [ "LoyaltyCard" => [ "SupplierCode" => "DL", "CardNumber" => "23434523" ] ], "TargetBranch" => "P878183", ] ]; Doing Soap Request:
$response = $this->soapClient->__soapCall('service', $request); I receive a Soap Fault:
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP:Body> <SOAP:Fault> <faultcode>Server.Data</faultcode> <faultstring>Error unmarshalling message body: Expected " {http://www.travelport.com/schema/sharedBooking_v41_0}BookingAirPnrElementReq" end tag, found "AddAirPnrElement" start tag (line 21, col 25, in UTF-8)</faultstring> <detail> <common_v41_0:ErrorInfo xmlns:common_v41_0="http://www.travelport.com/schema/common_v41_0"> <common_v41_0:Code>1005</common_v41_0:Code> <common_v41_0:Service>WEBSVC</common_v41_0:Service> <common_v41_0:Type>Data</common_v41_0:Type> <common_v41_0:Description>Unable to parse XML stream</common_v41_0:Description> <common_v41_0:TransactionId>C42964360A07425CB318E5F570EEE3DC</common_v41_0:TransactionId> </common_v41_0:ErrorInfo> </detail> </SOAP:Fault> </SOAP:Body> The XML request generated by SoapClient:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.travelport.com/schema/common_v41_0" xmlns:ns2="http://www.travelport.com/schema/sharedBooking_v41_0"> <SOAP-ENV:Header> <h:SessionContext xmlns:h="http://www.travelport.com/soa/common/security/SessionContext_v1" xmlns="http://www.travelport.com/soa/common/security/SessionContext_v1"> <SessTok id="9444dc84-87c9-4563-80ab-a5f6475bfbe9"/> </h:SessionContext> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns2:BookingAirPnrElementReq AuthorizedBy="user" TargetBranch="P878183" SessionKey="9444dc84-87c9-4563-80ab-a5f6475bfbe9"> <ns1:BillingPointOfSaleInfo OriginApplication="uAPI"/> <AddAirPnrElement> <ns1:LoyaltyCard CardNumber="23434523" SupplierCode="DL"/> </AddAirPnrElement> </ns2:BookingAirPnrElementReq> </SOAP-ENV:Body> </SOAP-ENV:Envelope> As you can see the AddAirPnrElement element does not have namespace ns2 that corresponds to the xmlns:ns2="http://www.travelport.com/schema/sharedBooking_v41_0"
If I add manually ns2 namespace to that element (AddAirPnrElement) and I send the same XML request in SoapUI, everything is ok. So the problem is that Soap Client does not set a namespace to that attribute.
Here is the WSDL:
<?xml version="1.0" encoding="UTF-8"?> <definitions name="SharedBookingService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.travelport.com/service/sharedBooking_v41_0" xmlns:ns1="http://www.travelport.com/schema/sharedBooking_v41_0" xmlns:sc="http://www.travelport.com/soa/common/security/SessionContext_v1" targetNamespace="http://www.travelport.com/service/sharedBooking_v41_0"> <import namespace="http://www.travelport.com/service/sharedBooking_v41_0" location="SharedBookingAbstract.wsdl"/> <binding name="BookingAirPnrElementBinding" type="tns:BookingAirPnrElementPortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="service"> <soap:operation soapAction="https://americas.universal-api.travelport.com/B2BGateway/connect/uAPI/SharedBookingService"/> <input> <soap:header use="literal" part="sessionContext" message="tns:SessionContext"/> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> <fault name="ErrorInfoMsg"> <soap:fault name="ErrorInfoMsg" use="literal"/> </fault> </operation> </binding> <service name="SharedBookingService"> <port name="BookingAirPnrElementPort" binding="tns:BookingAirPnrElementBinding"> <soap:address location="https://americas.universal-api.travelport.com/B2BGateway/connect/uAPI/SharedBookingService"/> </port> </service> </definitions> Can anyone help me understand why Soap Client does not set the namespace?
Thanks a lot.