How to add custom namespace using PHP SoapClient?

How to add custom namespace using PHP SoapClient? The namespace is not actually used in the request, but I think it prevents the correct consumption of my message.

WSDL is here: http://abr.business.gov.au/abrxmlsearchRPC/ABRXMLSearch.asmx?WSDL

The documentation for the specific message I want to send is here: http://abr.business.gov.au/abrxmlsearchRPC/(nye2ok45xc42vy552b15dx3t)/FormGenerator/ABRSearchByNameSimpleProtocol.aspx . I am making a SOAP request.

In the soap: Envelope, you will see a namespace called xmlns: types = "http://abr.business.gov.au/ABRXMLSearchRPC/encodedTypes", and you will also notice that it is not used in soap :. Body

The message I am posting is: (new lines and indentation added for readability, authenticationGuid confused for security)

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://abr.business.gov.au/ABRXMLSearchRPC/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
        <ns1:ABRSearchByNameSimpleProtocol>
            <name xsi:type="xsd:string">company</name>
            <postcode xsi:type="xsd:string"></postcode>
            <legalName xsi:type="xsd:string">Y</legalName>
            <tradingName xsi:type="xsd:string">Y</tradingName>
            <NSW xsi:type="xsd:string">Y</NSW>
            <SA xsi:type="xsd:string">Y</SA>
            <ACT xsi:type="xsd:string">Y</ACT>
            <VIC xsi:type="xsd:string">Y</VIC>
            <WA xsi:type="xsd:string">Y</WA>
            <NT xsi:type="xsd:string">Y</NT>
            <QLD xsi:type="xsd:string">Y</QLD>
            <TAS xsi:type="xsd:string">Y</TAS>
            <authenticationGuid xsi:type="xsd:string">aaaa</authenticationGuid>
        </ns1:ABRSearchByNameSimpleProtocol>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The answer I get is the following:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://abr.business.gov.au/ABRXMLSearchRPC/" xmlns:types="http://abr.business.gov.au/ABRXMLSearchRPC/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">    
        <types:ABRSearchByNameSimpleProtocolResponse><ABRSearchByNameSimpleProtocolResult href="#id1" /></types:ABRSearchByNameSimpleProtocolResponse>
        <types:Payload id="id1" xsi:type="types:Payload">
            <Request href="#id2" />
            <Response href="#id3" />
        </types:Payload>
        <types:ExternalRequest id="id2" xsi:type="types:ExternalRequest">           
            <ExternalRequestBody href="#id4" />
        </types:ExternalRequest>
        <types:Response id="id3" xsi:type="types:Response">
            <DateRegisterLastUpdated xsi:type="xsd:dateTime">0001-01-01T00:00:00.0000000+11:00</DateRegisterLastUpdated>
            <DateTimeRetrieved xsi:type="xsd:dateTime">2011-05-26T09:31:06.2949724+10:00</DateTimeRetrieved>
            <ResponseBody href="#id5" />
        </types:Response>
        <types:ExternalRequestNameSearch id="id4" xsi:type="types:ExternalRequestNameSearch">
            <AuthenticationGUID xsi:type="xsd:string" />
            <Name xsi:type="xsd:string" />
            <Filters href="#id6" />
        </types:ExternalRequestNameSearch>
        <types:ResponseException id="id5" xsi:type="types:ResponseException">
            <ExceptionDescription xsi:type="xsd:string">The GUID entered is not recognised as a Registered Party.

 Search GUID: </ExceptionDescription>
            <ExceptionCode xsi:type="xsd:string">WebServices</ExceptionCode>  
        </types:ResponseException>
        <types:ExternalRequestFilters id="id6" xsi:type="types:ExternalRequestFilters">
            <NameType href="#id7" />
            <Postcode xsi:type="xsd:string" />
            <StateCode href="#id8" />
        </types:ExternalRequestFilters>
        <types:ExternalRequestFilterNameType id="id7" xsi:type="types:ExternalRequestFilterNameType">
            <TradingName xsi:type="xsd:string">Y</TradingName>
            <LegalName xsi:type="xsd:string">Y</LegalName>
        </types:ExternalRequestFilterNameType>
        <types:ExternalRequestFilterStateCode id="id8" xsi:type="types:ExternalRequestFilterStateCode">
            <QLD xsi:type="xsd:string">Y</QLD>
            <NT xsi:type="xsd:string">Y</NT>
            <SA xsi:type="xsd:string">Y</SA>
            <WA xsi:type="xsd:string">Y</WA>
            <VIC xsi:type="xsd:string">Y</VIC>
            <ACT xsi:type="xsd:string">Y</ACT>
            <TAS xsi:type="xsd:string">Y</TAS>
            <NSW xsi:type="xsd:string">Y</NSW>
        </types:ExternalRequestFilterStateCode>
    </soap:Body>
</soap:Envelope>

It seems that the consumer has completely ignored the content of the message. The only thing I see in this example is the type namespace that is included in the response.

So, I think that if I can arbitrarily add a type namespace to the query, it might be more lucky.

If someone tells me how to do this, or suggest another suggestion why the consumer ignores the values ​​I gave in the request, that would be very helpful.

: SoapClient __doRequest() , -, . , SoapClient:: getLastRequest() , __doRequest(), , __doRequest(), , tcp.

class ABRSoapClient extends SoapClient {

    function __doRequest($request, $location, $action, $version) {
        $dom = new DOMDocument('1.0', 'UTF-8');
        $dom->preserveWhiteSpace = false;
        $dom->loadXML($request);

        $dom->documentElement->setAttribute
        ('xmlns:types', 'http://abr.business.gov.au/ABRXMLSearchRPC/encodedTypes');

        $request = $dom->saveXML();

        error_log('Request in class:'.$request);

        return parent::__doRequest($request, $location, $action, $version);
    }
}
+3

All Articles