I am writing PHP SOAP client that will connect to Java SOAP web service and the cliente needs to fetch some data from web service.
Web service wsdl files:
http://test.iaeste.net:8080/iws-ws/accessWS?wsdl
http://test.iaeste.net:8080/iws-ws/exchangeWS?wsdl
My code:
<?php
$soapURL = "http://test.iaeste.net:8080/iws-ws/accessWS?wsdl" ;
$options = array('features' =>
SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
$soapClient = new SoapClient($soapURL, $options);
$soapResult = $soapClient->generateSession(Array("password"=>"mypassword", "username"=> "myusername")) ;
var_dump($soapResult);
$token = $soapResult->token->token;
$obj= new stdClass();
$obj->exchangeYear=2015;
$obj->fetchType="SHARED";
$obj->token=$token;
$soapURL = "http://test.iaeste.net:8080/iws-ws/exchangeWS?wsdl" ;
$soapClient2 = new SoapClient($soapURL, $options);
$soapResult2 = $soapClient2->fetchOffers($obj) ;
//$soapResult2 = $soapClient2->fetchOffers(Array("exchangeYear"=> 2015,"fetchType"=>"SHARED" , "token"=>"$token" )) ;
var_dump($soapResult2);
echo "<br>";
$soapResult = $soapClient->deprecateSession(Array("token"=>"$token")) ;
var_dump($soapResult);
?>
Everything works correctly except fetchOffers method. I have also tried to send array instead of object. It is commented in code, but the result is the same. soapResult2 variable output is:
object(stdClass)#9 (2) { ["error"]=> object(stdClass)#10 (2) { ["error"]=> int(401) ["description"]=> string(54) "Given data is insufficient to properly handle request." } ["message"]=> string(57) "Validation failed: {fetchType=The field may not be null.}" }
I am little bit puzzeld with this problem, since it should work. I also have fetchType Java class and fetchOfferRequest Java class from web service, to properlly see how to format the objects.
FetchOfferRequest:
package net.iaeste.iws.ws;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for fetchOffersRequest complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="fetchOffersRequest">
* <complexContent>
* <extension base="{http://ws.iws.iaeste.net/}abstractPaginatable">
* <sequence>
* <element name="exchangeYear" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
* <element name="fetchType" type="{http://ws.iws.iaeste.net/}fetchType" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "fetchOffersRequest", propOrder = {
"exchangeYear",
"fetchType"
})
public class FetchOffersRequest
extends AbstractPaginatable
{
protected Integer exchangeYear;
protected FetchType fetchType;
/**
* Gets the value of the exchangeYear property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getExchangeYear() {
return exchangeYear;
}
/**
* Sets the value of the exchangeYear property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setExchangeYear(Integer value) {
this.exchangeYear = value;
}
/**
* Gets the value of the fetchType property.
*
* @return
* possible object is
* {@link FetchType }
*
*/
public FetchType getFetchType() {
return fetchType;
}
/**
* Sets the value of the fetchType property.
*
* @param value
* allowed object is
* {@link FetchType }
*
*/
public void setFetchType(FetchType value) {
this.fetchType = value;
}
}
FetchType:
package net.iaeste.iws.ws;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for fetchType.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* <simpleType name="fetchType">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="DOMESTIC"/>
* <enumeration value="SHARED"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "fetchType")
@XmlEnum
public enum FetchType {
DOMESTIC,
SHARED;
public String value() {
return name();
}
public static FetchType fromValue(String v) {
return valueOf(v);
}
}
I belive that this is all the information needed to solve this problem. If anyone knows how to help me, I would appreciate it.