I believe it should be possible for module to allow an override when parameters are passed. (needed this with custom wsdl)

Just implemented a hook that can be implemented by other modules. Perhaps not the best way but I saw no other possibility to set the correct parameters.

See patch for changed code.

Here is an example of the code I used in my module


/**
 * Implements hook_wsclient_parameter()
 * 
 * Overrides the parameters for getEvents
 */
function ao_service_wsclient_parameter($named_arguments, $operation) {
  if ($operation == 'getEvents') {
    $args_out['eventsRequest'] = $named_arguments['parameter'];     
    return $args_out;
  }
}
CommentFileSizeAuthor
#2 Screenshot-1.png168.14 KBdomidc
wsclient-parameter-override.patch800 bytesdomidc

Comments

klausi’s picture

Status: Active » Postponed (maintainer needs more info)

Hm, why would modules want to change parameters? The WSDL explicitly defines how parameters should be passed, so changing them would violate the service contract. What is your use case?

domidc’s picture

StatusFileSize
new168.14 KB

Well actually it kind of happend because the parameter was not correctly set when the wsdl was imported. In the screenshot you see it has parameter set instead of eventsRequest. I dont know if this is due to a malformed wsdl/xsd or due to an error in the import. It seems that the name is taken from the part instead of the element. Is that how it is supposed to be done? Anyways setting the setting to eventsRequest solved my problem. No need for the hook anymore.

<?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:tns="' . $soap_url . '"
      xmlns:von="' . $definition_url . '"
      targetNamespace="' . $definition_url . '">

      <wsdl:types>
        <xs:schema targetNamespace="' . $soap_url . '" elementFormDefault="unqualified" attributeFormDefault="unqualified">

          <xs:import namespace="' . $definition_url . '" schemaLocation="' . $von_xsd . '" />

          <xs:element name="eventsRequest">
            <xs:complexType>
              <xs:sequence>
                <xs:element ref="von:eventsRequest" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>

          <xs:element name="eventsResponse">
            <xs:complexType>
              <xs:sequence>
                <xs:element ref="von:eventsResponse" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>

        </xs:schema>
      </wsdl:types>

      <wsdl:message name="eventsRequest">
        <wsdl:part name="parameter" element="tns:eventsRequest" />
      </wsdl:message>

      <wsdl:message name="eventsResponse">
        <wsdl:part name="parameter" element="tns:eventsResponse" />
      </wsdl:message>

      <wsdl:portType name="AOPort">
        <wsdl:operation name="getEvents">
          <wsdl:input message="tns:eventsRequest" />
          <wsdl:output message="tns:eventsResponse" />
        </wsdl:operation>
      </wsdl:portType>

      <wsdl:binding name="AOBinding" type="tns:AOPort">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="getEvents">
          <soap:operation soapAction="urn:#getEvents" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>

      <wsdl:service name="AOService">
        <wsdl:port name="AOServiceBinding" binding="tns:AOBinding">
          <soap:address location="' . $soap_url . '" />
        </wsdl:port>
      </wsdl:service>

    </wsdl:definitions>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:von="' . $definition_url . '"
      targetNamespace="' . $definition_url . '" elementFormDefault="unqualified" attributeFormDefault="unqualified">

      <xs:element name="eventsRequest">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="lastUpdate" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>

      <xs:element name="projectsRequest">
      	<xs:complexType>
      		<xs:sequence>
      			<xs:element name="lastUpdate" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
      		</xs:sequence>
      	</xs:complexType>
      </xs:element>

      <xs:element name="eventsResponse">

      	<xs:complexType>
      		<xs:sequence>
      			<xs:element ref="von:event" minOccurs="0" maxOccurs="unbounded" />
      		</xs:sequence>
      	</xs:complexType>
      </xs:element>

      <xs:element name="projectsResponse">
      	<xs:complexType>

      		<xs:sequence>
      			<xs:element ref="von:project" minOccurs="0" maxOccurs="unbounded" />
      		</xs:sequence>
      	</xs:complexType>
      </xs:element>

      <xs:element name="event">
      	<xs:complexType>
      		<xs:sequence>

      			<xs:element name="eventId" type="xs:string" minOccurs="1" maxOccurs="1" />
      			<xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1" />
      			<xs:element name="description" type="xs:string" minOccurs="1" maxOccurs="1" />
      			<xs:element name="removed" type="xs:boolean" minOccurs="0" maxOccurs="1" />
      			<xs:element name="external" type="xs:boolean" minOccurs="1" maxOccurs="1" />
      			<xs:element name="organisation" type="xs:string" minOccurs="0" maxOccurs="1" />
      			<xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="1" />
      			<xs:element name="themes" minOccurs="0" maxOccurs="1">
      				<xs:complexType>

      					<xs:sequence>
      						<xs:element ref="von:theme" minOccurs="0" maxOccurs="unbounded" />
      					</xs:sequence>
      				</xs:complexType>
      			</xs:element>
      			<xs:element name="eventSessions" minOccurs="0" maxOccurs="1">
      				<xs:complexType>
      					<xs:sequence>
      						<xs:element ref="von:eventSession" minOccurs="1" maxOccurs="unbounded" />

      					</xs:sequence>
      				</xs:complexType>
      			</xs:element>
      		</xs:sequence>
      	</xs:complexType>
      </xs:element>

      <xs:element name="eventSession">
      	<xs:complexType>

      		<xs:sequence>
      			<xs:element name="eventSessionId" type="xs:string" minOccurs="1" maxOccurs="1" />
      			<xs:element name="soldOut" type="boolean" minOccurs="1" maxOccurs="1" />
      			<xs:element name="fromDate" type="xs:date" minOccurs="1" maxOccurs="1" />
      			<xs:element name="toDate" type="xs:date" minOccurs="1" maxOccurs="1" />
      			<xs:element name="location" type="xs:string" minOccurs="1" maxOccurs="1" />
      			<xs:element ref="von:province" minOccurs="1" maxOccurs="1" />
      			<xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="1" />
      		</xs:sequence>

      	</xs:complexType>
      </xs:element>

      <xs:element name="project">
      	<xs:complexType>
      		<xs:sequence>
      			<xs:element name="projectId" type="xs:string" minOccurs="1" maxOccurs="1" />
      			<xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1" />
      			<xs:element name="shortDescription" type="xs:string" minOccurs="0" maxOccurs="1" />

      			<xs:element name="description" type="xs:string" minOccurs="1" maxOccurs="1" />
      			<xs:element name="fromDate" type="xs:date" minOccurs="0" maxOccurs="1" />
      			<xs:element name="toDate" type="xs:date" minOccurs="0" maxOccurs="1" />
      			<xs:element name="projectStatus" type="von:projectStatus" minOccurs="0" maxOccurs="1" />
      			<xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="1" />
      			<xs:element name="themes" minOccurs="0" maxOccurs="1">
      				<xs:complexType>
      					<xs:sequence>
      						<xs:element ref="von:theme" minOccurs="0" maxOccurs="unbounded" />

      					</xs:sequence>
      				</xs:complexType>
      			</xs:element>
      			<xs:element name="organisators" minOccurs="0" maxOccurs="1">
      				<xs:complexType>
      					<xs:sequence>
      						<xs:element ref="von:organisator" minOccurs="0" maxOccurs="unbounded" />
      					</xs:sequence>
      				</xs:complexType>

      			</xs:element>
      			<xs:element name="targetgroups" minOccurs="0" maxOccurs="1">
      				<xs:complexType>
      					<xs:sequence>
      						<xs:element name="targetgroup" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
      					</xs:sequence>
      				</xs:complexType>
      			</xs:element>
      		</xs:sequence>

      	</xs:complexType>
      </xs:element>

      <xs:element name="theme">
      	<xs:complexType>
      		<xs:sequence>
      			<xs:element name="themeId" type="von:themeId" minOccurs="1" maxOccurs="1" />
      			<xs:element name="theme" type="xs:string" minOccurs="1" maxOccurs="1" />
      		</xs:sequence>

      	</xs:complexType>
      </xs:element>

      <xs:simpleType name="themeId">
      	<xs:restriction base="xs:string">
      		<!-- Subsidies -->
      		<xs:enumeration value="subsid" />
      		<!-- Financiering -->
      		<xs:enumeration value="financ" />

      		<!-- Vergunningen en regelgeving -->
      		<xs:enumeration value="vergreg" />
      		<!-- Starten met een bedrijf -->
      		<xs:enumeration value="startbedr" />
      		<!-- Groei en professionalisering -->
      		<xs:enumeration value="grprof" />
      		<!-- Opvolging, overname en stopzetting -->
      		<xs:enumeration value="opovrstop" />
      		<!-- Ruimtelijke orderning en bedrijfshuisvesting -->

      		<xs:enumeration value="ruimtord" />
      		<!-- Milieu en energie -->
      		<xs:enumeration value="milieu" />
      		<!-- Design en innovatie -->
      		<xs:enumeration value="desinno" />
      		<!-- IT: e-business en e-government -->
      		<xs:enumeration value="it" />
      		<!-- Eurpa en internationaal -->
      		<xs:enumeration value="euroint" />

      	</xs:restriction>
      </xs:simpleType>

      <xs:element name="province">
      	<xs:complexType>
      		<xs:sequence>
      			<xs:element name="provinceId" type="von:provinceId" minOccurs="1" maxOccurs="1" />
      			<xs:element name="province" type="xs:string" minOccurs="1" maxOccurs="1" />
      		</xs:sequence>

      	</xs:complexType>
      </xs:element>

      <xs:simpleType name="provinceId">
      	<xs:restriction base="xs:string">
      		<!-- Antwerpen -->
      		<xs:enumeration value="ant" />
      		<!-- Brussel -->
      		<xs:enumeration value="bru" />

      		<!-- Limburg -->
      		<xs:enumeration value="lim" />
      		<!-- Oost-Vlaanderen -->
      		<xs:enumeration value="ovl" />
      		<!-- West-Vlaanderen -->
      		<xs:enumeration value="wvl" />
      		<!-- Vlaams-Brabant -->
      		<xs:enumeration value="vlb" />
      	</xs:restriction>

      </xs:simpleType>

      <xs:simpleType name="projectStatus">
      	<xs:restriction base="xs:string">
      		<xs:enumeration value="toekomstig" />
      		<xs:enumeration value="lopend" />
      		<xs:enumeration value="afgelopen" />
      	</xs:restriction>
      </xs:simpleType>

      <xs:element name="organisator">

      	<xs:complexType>
      		<xs:sequence>
      			<xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
      			<xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="1" />
      		</xs:sequence>
      	</xs:complexType>
      </xs:element>

    </xs:schema>
klausi’s picture

Looks like a problem during the import of the WSDL. Can you post your WSDL without PHP variables in it so that I can test it?

klausi’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Reopen if this is still an issue.

And you can also use hook_wsclient_service_load() to mess around with operations and parameters after a service description has been loaded.