php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76142 Error generating request when /definitions/types/schema.targetNamespace not set
Submitted: 2018-03-23 11:24 UTC Modified: 2018-03-23 14:27 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: VadimZelenin at gmail dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.6.34 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: VadimZelenin at gmail dot com
New email:
PHP Version: OS:

 

 [2018-03-23 11:24 UTC] VadimZelenin at gmail dot com
Description:
------------
I need interoperate with service for which /definitions/types/schema.targetNamespace is not set.

SoapUI 5.3.0 can form request template to such service -

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <AddLocation>
         <id>?</id>
         <placeId>?</placeId>
         <!--Optional:-->
         <prefix>?</prefix>
      </AddLocation>
   </soapenv:Body>
</soapenv:Envelope>


www.wsdl-analyzer.com too -
<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:AddLocation xmlns:ns1=''>
      <ns1:id>?XXX?</ns1:id>
      <ns1:placeId>?XXX?</ns1:placeId>
<!-- optional -->
      <ns1:prefix />
    </ns1:AddLocation>
  </s11:Body>
</s11:Envelope>

But SoapClient from php (5.6.33) can not. 

Please advise workaround.

Test script:
---------------
#!/usr/bin/php
<?php

class CustomSoapClient extends SoapClient
{
    public function __doRequest($aRequest, $aLocation, $aAction, $aVersion, $aOneWay=0)
    {
        print_r( $aRequest );
        exit(0);
    }
};

$WSDL='<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:AddLocationService" targetNamespace="urn:AddLocationService">
    <wsdl:types>
        <s:schema elementFormDefault="qualified">
            <s:complexType name="AddLocationRequest">
                <s:sequence>
                    <s:element name="id" type="s:string"/>
                    <s:element name="placeId" type="s:string"/>
                    <s:element minOccurs="0" name="prefix"/>
                </s:sequence>
            </s:complexType>
            <s:element name="AddLocation" type="AddLocationRequest"/>
        </s:schema>
    </wsdl:types>
    <wsdl:message name="AddLocationSoapIn">
        <wsdl:part name="parameters" element="AddLocation"/>
    </wsdl:message>
    <wsdl:message name="AddLocationSoapOut"/>
    <wsdl:portType name="ERLocationScheduleServiceSoap">
        <wsdl:operation name="AddLocation">
            <wsdl:input message="tns:AddLocationSoapIn"/>
            <wsdl:output message="tns:AddLocationSoapOut"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="ERLocationScheduleServiceSoap" type="tns:ERLocationScheduleServiceSoap">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="AddLocation">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="ERLocationScheduleService">
        <wsdl:port name="ERLocationScheduleServiceSoap" binding="tns:ERLocationScheduleServiceSoap">
            <soap:address location="http://private.serv/bogus.cls"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>';

ini_set('soap.wsdl_cache_enabled', 0);

$client = new CustomSoapClient('data:application/wsdl+xml;base64,' . base64_encode($WSDL));

$request = array( 'id'=>'1',
                  'placeId' => '123',
                  'prefix'  => 'xyz',
                );

$client->AddLocation($request);

?>


Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <AddLocation>
            <id>1</ns1:id>
            <placeId>123</ns1:placeId>
            <prefix>xyz</ns1:prefix>
        </AddLocation>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <parameters>
            <item>
                <key>id</key>
                <value>1</value>
            </item>
            <item>
                <key>placeId</key>
                <value>123</value>
            </item>
            <item>
                <key>prefix</key>
                <value>xyz</value>
            </item>
        </parameters>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-23 14:27 UTC] VadimZelenin at gmail dot com
oops, Expected result must be:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <AddLocation>
            <id>1</id>
            <placeId>123</placeId>
            <prefix>xyz</prefix>
        </AddLocation>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Wed Dec 12 13:01:26 2018 UTC