Q:

PHP curl Soap Request Error

I have encountered interesting event.  I  send soap request by using curl , but I get error in  response as following. But When I try  same request  on SoapUI , I get successful response , so I can't understand why I get error on php curl.
The error:
 soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header />
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>soapenv:Client</faultcode>
            <faultstring>java.lang.RuntimeException: Unexpected subelement Envelope</faultstring>
            <detail />
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

The Request:
     <s:Envelope xmlns:s = "http://schemas.xmlsoap.org/soap/envelope/">
    <Header xmlns="http://schemas.xmlsoap.org/soap/envelope/">
        <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <UsernameToken>
                <Username>MARMARAXML</Username>
                <Password>12345</Password>
            </UsernameToken>
        </Security>
    </Header>
    <s:Body xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
        <OTA_AirAvailRQ xmlns="http://otabase.otapax.otaxmlws/">
            <POS xmlns="http://ota.paxws.otaxmlws/">
                <Source xmlns="http://types.paxws.otaxmlws/" isoCountry="NL" isoCurrency="EUR">
                    <RequestorID/>
                    <BookingChannel/>
                </Source>
            </POS>
            <OriginDestinationInformation xmlns="http://ota.paxws.otaxmlws/">
                <DepartureDateTime xmlns="http://types.paxws.otaxmlws/">2015-03-07</DepartureDateTime>
                <OriginLocation xmlns="http://types.paxws.otaxmlws/" LocationCode="AMS"/>
                <DestinationLocation xmlns="http://types.paxws.otaxmlws/" LocationCode="IST"/>
            </OriginDestinationInformation>
            <TravelPreferences xmlns="http://ota.paxws.otaxmlws/">
                <FlightTypePref xmlns="http://types.paxws.otaxmlws/"/>
                <EquipPref xmlns="http://types.paxws.otaxmlws/"/>
                <CabinPref xmlns="http://types.paxws.otaxmlws/"/>
                <TicketDistribPref xmlns="http://types.paxws.otaxmlws/"/>
                <BookingClassPref xmlns="http://types.paxws.otaxmlws/"/>
            </TravelPreferences>
            <TravelerInfoSummary xmlns="http://ota.paxws.otaxmlws/">
                <AirTravelerAvail xmlns="http://types.paxws.otaxmlws/">
                    <PassengerTypeQuantity Code="ADT" Quantity="1"/>
                    <temp>String</temp>
                </AirTravelerAvail>
            </TravelerInfoSummary>
        </OTA_AirAvailRQ>
    </s:Body>
</s:Envelope>

the PHP code is
$soap_do = curl_init($account[OnurAccount::ENDPOINT]);
        $header = array(
            "Content-Type: text/xml;charset=UTF-8",
            "Cache-Control: no-cache",
            "Pragma: no-cache",
            "SOAPAction:/".$soapAction,
            "Content-length: " . strlen($message),
        );
        curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 300);
        curl_setopt($soap_do, CURLOPT_TIMEOUT, 30);
        curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($soap_do, CURLOPT_POST, true);
        //curl_setopt($soap_do, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT);
        curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($soap_do, CURLOPT_POSTFIELDS, $message);
        curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);

        $result_xml = curl_exec($soap_do);

The Wsdl adress: http://onur-stage.crane.aero/axis2/services/CraneOTAService?wsdl
Thanks,

A:

Using the follow curl command I call successfully your webservice using the request you post in your question:
curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:/Availability" --data @request.xml http://onur-stage.crane.aero:80/axis2/services/CraneOTAService
Where:
--header "Content-Type: text/xml;charset=UTF-8" add the correct Content-type http-header for typically SOAP requests.
--header "SOAPAction:/Availability" includes the required http-header SOAPAction for your WS.
--data @request.xml points to your request which I save in a request.xml file inside the same path where I execute the command.
And I receive the follow response (which I suppose it's expected).
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header />
    <soapenv:Body>
        <ns2:OTA_AirAvailRSType xmlns:ns2="http://ota.paxws.otaxmlws/" SequenceNmbr="1" TimeStamp="2015-03-06 13:29:06.166">
            <Success xmlns="http://ota.paxws.otaxmlws/">true</Success>
            <OriginDestinationOptions xmlns="http://ota.paxws.otaxmlws/">
                <OriginDestinationOption xmlns="http://types.paxws.otaxmlws/">
                    <FlightSegment ArrivalDateTime="2015-03-07 19:25:00.0" DepartureDateTime="2015-03-07 14:55:00.0" FlightNumber="372" JourneyDuration="" OnTimeRate="" RPH="" ResBookDesigCode="" ResBookDesigID="" Status="" StopQuantity="0" Ticket="">
                        <DepartureAirport LocationCode="AMS" />
                        <ArrivalAirport LocationCode="IST" />
                        <Equipment AirEquipType="A320-232 / 180Y" ChangeofGauge="NONE" />
                        <MarkettingAirline CompanyShortName="8Q" />
                        <MarketingCabin CabinType="" RPH="0">
                            <Meal>*</Meal>
                        </MarketingCabin>
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="A" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="D" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="Y" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="Q" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="B" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="L" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="M" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="H" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="K" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="N" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="S" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="I" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="V" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="W" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="T" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="U" ResBookDesigQuantity="9" />
                        <BookingClassAvail CabinType="" RPH="0" ResBookDesigCode="P" ResBookDesigQuantity="9" />
                        <comment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
                    </FlightSegment>
                    <dummy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
                </OriginDestinationOption>
                <dummy xmlns="http://types.paxws.otaxmlws/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            </OriginDestinationOptions>
        </ns2:OTA_AirAvailRSType>
    </soapenv:Body>
</soapenv:Envelope>

Hope this helps,

