RE: [SOAP] SoapServer and integer types question
[email protected] (Bruce Bailey)
| Newsgroups | php.soap |
|---|---|
| Message-ID | <[email protected]> |
Justin
Here's some sample code that duplicates the problem. I don't know how to make it shorter and self contained, sorry about that.
Bruce
Issue - Integer types 'xsd:long' (64 bits) and 'xsd:int' (unlimited?) change longer (>31 bit) integers in the SoapServer object to 2147483647.
Using soapUI I sent the following request document:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ssd="http://www.example.org/ssdefect/">
<soapenv:Header/>
<soapenv:Body>
<ssd:NewOperation>
<in>5000000000</in>
</ssd:NewOperation>
</soapenv:Body>
</soapenv:Envelope>
The reply document was:
<soap-env:envelope
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://www.example.org/ssdefect/">
<SOAP-ENV:Body>
<ns1:NewOperationResponse>
<longtype>2147483647</longtype>
<stringtype>5000000000</stringtype>
<inttype>2147483647</inttype>
<integertype>2147483647</integertype>
<decimaltype>5000000000</decimaltype>
</ns1:NewOperationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Both 'longtype' and 'inttype' should have been '5000000000'.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< php begin >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?
class SSDefect
{
public function NewOperation($in)
{
$retval["stringtype"] = $in->in;
$retval["longtype"] = $in->in;
$retval["inttype"] = $in->in;
$retval["integertype"]= $in->in;
$retval["decimaltype"]= $in->in;
return $retval;
}
}
ini_set('soap.wsdl_cache_enabled', '0');
$server = new SoapServer('ssdefect.wsdl');
$server->setClass('SSDefect');
$server->handle();
?>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< php end >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< wsdl begin >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<wsdl:definitions name="ssdefect"
targetNamespace="http://www.example.org/ssdefect/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.org/ssdefect/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/ssdefect/">
<xsd:element name="NewOperation">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="NewOperationResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="longtype" type="xsd:long"/>
<xsd:element name="stringtype" type="xsd:string"/>
<xsd:element name="inttype" type="xsd:int"/>
<xsd:element name="integertype" type="xsd:integer"/>
<xsd:element name="decimaltype" type="xsd:decimal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="NewOperationRequest">
<wsdl:part element="tns:NewOperation" name="parameters"/>
</wsdl:message>
<wsdl:message name="NewOperationResponse">
<wsdl:part element="tns:NewOperationResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="ssdefect">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:NewOperationRequest"/>
<wsdl:output message="tns:NewOperationResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ssdefectSOAP" type="tns:ssdefect">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="NewOperation">
<soap:operation soapAction="http://www.example.org/ssdefect/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ssdefect">
<wsdl:port binding="tns:ssdefectSOAP" name="ssdefectSOAP">
<soap:address location="http://xxx.xxx.xxx.xxx/ssdefect"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< wsdl end >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Date: Wed, 27 Jan 2010 11:34:57 -0500
Subject: Re: [SOAP] SoapServer and integer types question
From: [email protected]
To: [email protected]
Bruce,
I would certainly consider that a defect. W3schools agrees with you(http://www.w3schools.com/schema/schema_dtypes_numeric.asp). So does the W3C (http://www.w3.org/TR/xmlschema-2/#long)
If you were to enter a bug I'd vote for it. That being said I'm not a committer and a n00b to hacking the PHP source itself.
I've gotten the 5.3 branch of php to build from SVN and I can step through the soap extension in visual studio.I'm a total newb to PHP hacking, but if you can provide a complete PHP script that reproduces the error I'll see if I can make a quick patch to fix the issue.
Regards,
Justin Dearing
On Wed, Jan 27, 2010 at 11:23 AM, Bruce Bailey <[email protected]> wrote:
Thanks all for your replies. According to my limited understanding of schemas, xs:long types would need 64 bits to represent. However, SoapServer doesn't seem to recognize that. Wouldn't that be considered a defect? Should I enter a defect here?
Thanks,
Bruce
> Date: Tue, 26 Jan 2010 19:18:09 +0100
> From: [email protected]
> To: [email protected]
> Subject: Re: [SOAP] SoapServer and integer types question
>
> just string ;)
>
> Bruce Bailey pisze:
> > Hi
> >
> > I'm using the SoapServer class (in PHP5.2.3) and noticing what seems like incorrect behavior.
> >
> > When I have 10 digit (or greater) integer values returned from the SoapServer, they seem to overflow.
> >
> > For example:
> >
> > Schema type (from WSDL): xs:long (or xs:int or xs:integer)
> > Returned value (from network trace): <value>2147483647</value>
> >
> > Expected value: <value>3605736641</value>
> >
> >
> > Is this correct behavior?
> >
> > I find that if I use xs:decimal for the type, I get my expected value back from SoapServer, but I'm concerned that there are unexpected consequences waiting for me in the future.
> >
> > What have other people done in this type of situation?
> >
> > Thanks in advance,
> >
> > Bruce
> >
> > _________________________________________________________________
> > Hotmail: Powerful Free email with security by Microsoft.
> > http://clk.atdmt.com/GBL/go/196390710/direct/01/
> >
>
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/196390708/direct/01/
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/196390709/direct/01/