SOAP
Ik heb een vraag.
Ik ben bezig met een SOAP client met nuSoap.
Ik had dit nog nooit gedaan, maar na veel lezen en zoeken en proberen heb ik de verbinding voor elkaar.
Het is in principe geen probleem maar de server draait php4, dus ik kan de php5 build in soap lib niet gebruiken en ik moest een WSSecurity header inbouwen, wat volgens vele niet ondersteund wordt door nuSoap.
Dat ondersteund het dus wel, via de functie setHeaders(), alleen dit wordt slecht gedocumenteerd.
Maar goed, terug naar het probleem.
Ik heb dus verbinding en naar mijn weten roep ik de juiste functie aan met de juiste parameters die allemaal netjes in een array staan.
Toch ontvang ik de volgende error melding als ik het script uitvoer.
phpType is struct, but value is not an array: see debug output for details.
Nou kan ik uit de debug info geen oplossing halen, want volgens mij stuur ik toch echt een array met parameters.
Dit zijn de regels waarmee ik de functie aanroep.
Code (php)
1
2
3
2
3
$params = array('accountDetails' => array('name' => 'MyName','address' => 'MyAddress','zipcode' => 'MyZipcode','city' => 'MyCity','country' => 'MyCountry','phoneNumber' => 'MyPhoneNumber','emailAddress' => 'MyEmailAddress','hashedPassword' => 'MyPassword','companyName' => 'MyCompanyName'));
$result=$client->call('createDemoAccount', array('createDemoAccountRequest', $params));
$result=$client->call('createDemoAccount', array('createDemoAccountRequest', $params));
Dit is het wsdl bestand:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:schema="***" xmlns:soap="***" xmlns:tns="***" targetNamespace="***">
- <wsdl:types>
- <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ns5="***" xmlns:tns="***" elementFormDefault="qualified" targetNamespace="***">
<import namespace="***" schemaLocation="***" />
- <element name="getCustomersResponse">
- <complexType>
- <sequence>
<element maxOccurs="unbounded" minOccurs="0" name="customers" type="ns5:CustomerType" />
</sequence>
</complexType>
</element>
- <element name="getCustomersRequest">
- <complexType>
<sequence />
</complexType>
</element>
- <element name="getSubscriptionTypesResponse">
- <complexType>
- <sequence>
<element maxOccurs="unbounded" minOccurs="1" name="subscriptionTypes" type="ns5:SubscriptionTypeType" />
</sequence>
</complexType>
</element>
- <element name="getSubscriptionTypesRequest">
- <complexType>
<sequence />
</complexType>
</element>
- <element name="deleteCustomerRequest">
- <complexType>
- <sequence>
<element maxOccurs="1" minOccurs="1" name="customerId" type="long" />
</sequence>
</complexType>
</element>
- <element name="deleteCustomerResponse">
- <complexType>
<sequence />
</complexType>
</element>
- <element name="createDemoAccountRequest">
- <complexType>
- <sequence>
<element maxOccurs="1" minOccurs="1" name="accountDetails" type="tns:AccountDetailsType" />
</sequence>
</complexType>
</element>
- <element name="createDemoAccountResponse">
- <complexType>
- <sequence>
<element maxOccurs="1" minOccurs="1" name="customerId" type="long" />
<element maxOccurs="1" minOccurs="1" name="username" type="string" />
</sequence>
</complexType>
</element>
- <complexType name="AccountDetailsType">
- <sequence>
<element maxOccurs="1" minOccurs="1" name="name" type="string" />
<element maxOccurs="1" minOccurs="1" name="address" type="string" />
<element maxOccurs="1" minOccurs="1" name="zipcode" type="string" />
<element maxOccurs="1" minOccurs="1" name="city" type="string" />
<element maxOccurs="1" minOccurs="1" name="country" type="string" />
<element maxOccurs="1" minOccurs="1" name="phoneNumber" type="string" />
<element maxOccurs="1" minOccurs="1" name="emailAddress" type="string" />
<element maxOccurs="1" minOccurs="1" name="hashedPassword" type="string" />
<element maxOccurs="1" minOccurs="1" name="companyName" type="string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
- <wsdl:message name="createDemoAccountRequest">
<wsdl:part element="schema:createDemoAccountRequest" name="createDemoAccountRequest" />
</wsdl:message>
- <wsdl:message name="getSubscriptionTypesResponse">
<wsdl:part element="schema:getSubscriptionTypesResponse" name="getSubscriptionTypesResponse" />
</wsdl:message>
- <wsdl:message name="getCustomersRequest">
<wsdl:part element="schema:getCustomersRequest" name="getCustomersRequest" />
</wsdl:message>
- <wsdl:message name="deleteCustomerRequest">
<wsdl:part element="schema:deleteCustomerRequest" name="deleteCustomerRequest" />
</wsdl:message>
- <wsdl:message name="getSubscriptionTypesRequest">
<wsdl:part element="schema:getSubscriptionTypesRequest" name="getSubscriptionTypesRequest" />
</wsdl:message>
- <wsdl:message name="getCustomersResponse">
<wsdl:part element="schema:getCustomersResponse" name="getCustomersResponse" />
</wsdl:message>
- <wsdl:message name="deleteCustomerResponse">
<wsdl:part element="schema:deleteCustomerResponse" name="deleteCustomerResponse" />
</wsdl:message>
- <wsdl:message name="createDemoAccountResponse">
<wsdl:part element="schema:createDemoAccountResponse" name="createDemoAccountResponse" />
</wsdl:message>
- <wsdl:portType name="Customers">
- <wsdl:operation name="createDemoAccount">
<wsdl:input message="tns:createDemoAccountRequest" name="createDemoAccountRequest" />
<wsdl:output message="tns:createDemoAccountResponse" name="createDemoAccountResponse" />
</wsdl:operation>
- <wsdl:operation name="getCustomers">
<wsdl:input message="tns:getCustomersRequest" name="getCustomersRequest" />
<wsdl:output message="tns:getCustomersResponse" name="getCustomersResponse" />
</wsdl:operation>
- <wsdl:operation name="deleteCustomer">
<wsdl:input message="tns:deleteCustomerRequest" name="deleteCustomerRequest" />
<wsdl:output message="tns:deleteCustomerResponse" name="deleteCustomerResponse" />
</wsdl:operation>
- <wsdl:operation name="getSubscriptionTypes">
<wsdl:input message="tns:getSubscriptionTypesRequest" name="getSubscriptionTypesRequest" />
<wsdl:output message="tns:getSubscriptionTypesResponse" name="getSubscriptionTypesResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="CustomersBinding" type="tns:Customers">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="createDemoAccount">
<soap:operation soapAction="" />
- <wsdl:input name="createDemoAccountRequest">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="createDemoAccountResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="getCustomers">
<soap:operation soapAction="" />
- <wsdl:input name="getCustomersRequest">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="getCustomersResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="deleteCustomer">
<soap:operation soapAction="" />
- <wsdl:input name="deleteCustomerRequest">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="deleteCustomerResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="getSubscriptionTypes">
<soap:operation soapAction="" />
- <wsdl:input name="getSubscriptionTypesRequest">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="getSubscriptionTypesResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="CustomersService">
- <wsdl:port binding="tns:CustomersBinding" name="CustomersPort">
<soap:address location="********" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:schema="***" xmlns:soap="***" xmlns:tns="***" targetNamespace="***">
- <wsdl:types>
- <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ns5="***" xmlns:tns="***" elementFormDefault="qualified" targetNamespace="***">
<import namespace="***" schemaLocation="***" />
- <element name="getCustomersResponse">
- <complexType>
- <sequence>
<element maxOccurs="unbounded" minOccurs="0" name="customers" type="ns5:CustomerType" />
</sequence>
</complexType>
</element>
- <element name="getCustomersRequest">
- <complexType>
<sequence />
</complexType>
</element>
- <element name="getSubscriptionTypesResponse">
- <complexType>
- <sequence>
<element maxOccurs="unbounded" minOccurs="1" name="subscriptionTypes" type="ns5:SubscriptionTypeType" />
</sequence>
</complexType>
</element>
- <element name="getSubscriptionTypesRequest">
- <complexType>
<sequence />
</complexType>
</element>
- <element name="deleteCustomerRequest">
- <complexType>
- <sequence>
<element maxOccurs="1" minOccurs="1" name="customerId" type="long" />
</sequence>
</complexType>
</element>
- <element name="deleteCustomerResponse">
- <complexType>
<sequence />
</complexType>
</element>
- <element name="createDemoAccountRequest">
- <complexType>
- <sequence>
<element maxOccurs="1" minOccurs="1" name="accountDetails" type="tns:AccountDetailsType" />
</sequence>
</complexType>
</element>
- <element name="createDemoAccountResponse">
- <complexType>
- <sequence>
<element maxOccurs="1" minOccurs="1" name="customerId" type="long" />
<element maxOccurs="1" minOccurs="1" name="username" type="string" />
</sequence>
</complexType>
</element>
- <complexType name="AccountDetailsType">
- <sequence>
<element maxOccurs="1" minOccurs="1" name="name" type="string" />
<element maxOccurs="1" minOccurs="1" name="address" type="string" />
<element maxOccurs="1" minOccurs="1" name="zipcode" type="string" />
<element maxOccurs="1" minOccurs="1" name="city" type="string" />
<element maxOccurs="1" minOccurs="1" name="country" type="string" />
<element maxOccurs="1" minOccurs="1" name="phoneNumber" type="string" />
<element maxOccurs="1" minOccurs="1" name="emailAddress" type="string" />
<element maxOccurs="1" minOccurs="1" name="hashedPassword" type="string" />
<element maxOccurs="1" minOccurs="1" name="companyName" type="string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
- <wsdl:message name="createDemoAccountRequest">
<wsdl:part element="schema:createDemoAccountRequest" name="createDemoAccountRequest" />
</wsdl:message>
- <wsdl:message name="getSubscriptionTypesResponse">
<wsdl:part element="schema:getSubscriptionTypesResponse" name="getSubscriptionTypesResponse" />
</wsdl:message>
- <wsdl:message name="getCustomersRequest">
<wsdl:part element="schema:getCustomersRequest" name="getCustomersRequest" />
</wsdl:message>
- <wsdl:message name="deleteCustomerRequest">
<wsdl:part element="schema:deleteCustomerRequest" name="deleteCustomerRequest" />
</wsdl:message>
- <wsdl:message name="getSubscriptionTypesRequest">
<wsdl:part element="schema:getSubscriptionTypesRequest" name="getSubscriptionTypesRequest" />
</wsdl:message>
- <wsdl:message name="getCustomersResponse">
<wsdl:part element="schema:getCustomersResponse" name="getCustomersResponse" />
</wsdl:message>
- <wsdl:message name="deleteCustomerResponse">
<wsdl:part element="schema:deleteCustomerResponse" name="deleteCustomerResponse" />
</wsdl:message>
- <wsdl:message name="createDemoAccountResponse">
<wsdl:part element="schema:createDemoAccountResponse" name="createDemoAccountResponse" />
</wsdl:message>
- <wsdl:portType name="Customers">
- <wsdl:operation name="createDemoAccount">
<wsdl:input message="tns:createDemoAccountRequest" name="createDemoAccountRequest" />
<wsdl:output message="tns:createDemoAccountResponse" name="createDemoAccountResponse" />
</wsdl:operation>
- <wsdl:operation name="getCustomers">
<wsdl:input message="tns:getCustomersRequest" name="getCustomersRequest" />
<wsdl:output message="tns:getCustomersResponse" name="getCustomersResponse" />
</wsdl:operation>
- <wsdl:operation name="deleteCustomer">
<wsdl:input message="tns:deleteCustomerRequest" name="deleteCustomerRequest" />
<wsdl:output message="tns:deleteCustomerResponse" name="deleteCustomerResponse" />
</wsdl:operation>
- <wsdl:operation name="getSubscriptionTypes">
<wsdl:input message="tns:getSubscriptionTypesRequest" name="getSubscriptionTypesRequest" />
<wsdl:output message="tns:getSubscriptionTypesResponse" name="getSubscriptionTypesResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="CustomersBinding" type="tns:Customers">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="createDemoAccount">
<soap:operation soapAction="" />
- <wsdl:input name="createDemoAccountRequest">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="createDemoAccountResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="getCustomers">
<soap:operation soapAction="" />
- <wsdl:input name="getCustomersRequest">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="getCustomersResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="deleteCustomer">
<soap:operation soapAction="" />
- <wsdl:input name="deleteCustomerRequest">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="deleteCustomerResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="getSubscriptionTypes">
<soap:operation soapAction="" />
- <wsdl:input name="getSubscriptionTypesRequest">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="getSubscriptionTypesResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="CustomersService">
- <wsdl:port binding="tns:CustomersBinding" name="CustomersPort">
<soap:address location="********" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Ik hoop dat iemand mij kan helpen... :)
Ik heb het inmiddels opgelost.
De call zat niet goed in elkaar. ;-)
Hoe is het dan nu geworden? Dan leren we er allemaal weer van :D
Het was iets heel kleins in de omschrijving van de params en het aanroepen van de functie.
Eerste was het:
Code (php)
1
2
3
2
3
$params = array('accountDetails' => array('name' => 'MyName','address' => 'MyAddress','zipcode' => 'MyZipcode','city' => 'MyCity','country' => 'MyCountry','phoneNumber' => 'MyPhoneNumber','emailAddress' => 'MyEmailAddress','hashedPassword' => 'MyPassword','companyName' => 'MyCompanyName'));
$result=$client->call('createDemoAccount', array('createDemoAccountRequest', $params));
$result=$client->call('createDemoAccount', array('createDemoAccountRequest', $params));
En het is geworden:
Code (php)
1
2
3
2
3
$params = array('createDemoAccountRequest'=>array('accountDetails'=>array('name' => 'myName','address' => 'myAddress','zipcode' => 'myZipcode','city' => 'myCity','country' => 'myCountry','phoneNumber' => 'myPhonenumber','emailAddress' => 'myEmailaddress','hashedPassword' => 'myPassword','companyName' => 'myCompanyname')));
$result=$client->call('createDemoAccount', $params);
$result=$client->call('createDemoAccount', $params);
Dus in feite prak je alles waar createDemoAccount naar op zoek is in $params en call je het met als parameters $params.