PHP Soap to .NET client
Posted: Thu Feb 10, 2011 4:25 pm
I have a PHP server that was created with the included PHP Soap module. The huge downside is there is no WSDL generator.
I have been able to pass things with this WSDL, a complex object with a known number of fields. Now I am trying to pass an image (or multiple images) depending on how many have been scanned.
The WSDL code for this part is
The php code:
I would have prefered to use base64Binary but this is failing with the .NET client with the following error:
[text]System.InvalidOperationException: Method ShipmentStatusService.getImage can
not be reflected. ---> System.InvalidOperationException: There was an error
reflecting 'getImageResult'. ---> System.InvalidOperationException:
'base64Binary' is an invalid value for the SoapElementAttribute.DataType
property. The property may only be specified for primitive types.[/text]
When I use my PHP test client, I am able to get this object returned fine
This leads me to believe everything is working properly. With the .NET client, it receives the following error:
[text]System.InvalidOperationException: There is an error in XML document (2,
71820). ---> System.InvalidCastException: Cannot assign object of type
System.String to an object of type System.String[].[/text]
With that error, it happens on the last character of the </image> tag. I tried using serialize and XML_Serializer with some web suggestions but this didn't seem to work (no data appeared to be returned).
Are there any suggestions on what to change in my server code, or wsdl, or something in between that needs to be modified?
I have been able to pass things with this WSDL, a complex object with a known number of fields. Now I am trying to pass an image (or multiple images) depending on how many have been scanned.
The WSDL code for this part is
Code: Select all
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="images" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ImageObject">
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="image" type="tns:ArrayOfString" />
</xsd:sequence>
</xsd:complexType>Code: Select all
$imageList = new ImageObject();
for($i=1;$i<=$totalPages;$i++){
$filename = $this->IMAGE_PATH.$imageid.'_'.$i.'.png';
$imgbinary = fread(fopen($filename, "r"), filesize($filename));
$imagedata = base64_encode($imgbinary);
$imageList->addImage($imagedata);
}
return $imageList;
class ImageObject{
var $image;
function __construct(){
$this->image=array();
}
function addImage($image){
$this->image[] = $image;
}
}[text]System.InvalidOperationException: Method ShipmentStatusService.getImage can
not be reflected. ---> System.InvalidOperationException: There was an error
reflecting 'getImageResult'. ---> System.InvalidOperationException:
'base64Binary' is an invalid value for the SoapElementAttribute.DataType
property. The property may only be specified for primitive types.[/text]
When I use my PHP test client, I am able to get this object returned fine
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:[removed]" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="[removed]" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getImageResponse><imageobject xsi:type="ns2:ImageObject"><image xsi:type="ns2:ArrayOfString"><images xsi:type="xsd:string">[encoded data removed]</images>
</image></imageobject></ns1:getImageResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>[text]System.InvalidOperationException: There is an error in XML document (2,
71820). ---> System.InvalidCastException: Cannot assign object of type
System.String to an object of type System.String[].[/text]
With that error, it happens on the last character of the </image> tag. I tried using serialize and XML_Serializer with some web suggestions but this didn't seem to work (no data appeared to be returned).
Are there any suggestions on what to change in my server code, or wsdl, or something in between that needs to be modified?