Home > php教程 > php手册 > body text

【原】使用wsdl的注意事项

WBOY
Release: 2016-06-13 10:18:02
Original
806 people have browsed it

<span 1</span> <span <</span><span wsdl:message </span><span name</span><span ="MinusIn"</span><span ></span>
<span 2</span>        <span <</span><span wsdl:part </span><span name</span><span ="parameters1"</span><span  element</span><span ="s::int"</span><span /></span>
<span 3</span>        <span <</span><span wsdl:part </span><span name</span><span ="parameters2"</span><span  element</span><span ="s::int"</span><span /></span>
<span 4</span> <span </</span><span wsdl:message</span><span ></span>
Copy after login
<span 1</span> <span <</span><span wsdl:message </span><span name</span><span ="MinusIn"</span><span ></span>
<span 2</span>       <span <</span><span wsdl:part </span><span name</span><span ="parameters1"</span><span  element</span><span ="s:int"</span><span /></span>
<span 3</span>       <span <</span><span wsdl:part </span><span name</span><span ="parameters2"</span><span  element</span><span ="s:int"</span><span /></span>
<span 4</span> <span </</span><span wsdl:message</span><span ></span>
Copy after login
<span 1</span> <span function</span> Minus2(<span $i</span>, <span $j</span><span )
</span><span 2</span> <span {
</span><span 3</span>       <span $add</span> = <span $i</span> + <span $j</span><span ;
</span><span 4</span>       <span $sub</span> = <span $i</span> - <span $j</span><span ;
</span><span 5</span>       <span return</span> <span array</span>("add"=><span $add</span>, "sub"=><span $sub</span><span );
</span><span 6</span> }
Copy after login
<span 1</span> <span <</span><span wsdl:message </span><span name</span><span ="MinusOut"</span><span ></span>
<span 2</span>        <span <</span><span wsdl:part </span><span name</span><span ="add"</span><span  element</span><span ="s:int"</span> <span /></span>
<span 3</span>        <span <</span><span wsdl:part </span><span name</span><span ="sub"</span><span  element</span><span ="s:int"</span> <span /></span>
<span 4</span> <span </</span><span wsdl:message</span><span ></span>
Copy after login
<span 1</span> <span $ret</span> = <span $client</span>->Minus2(100, 99<span );
</span><span 2</span> <span var_dump</span>(<span $ret</span><span );
</span><span 3</span> <span array</span>(2) { 'add' => <span string</span>(3) "199" 'sub' => <span string</span>(1) "1" }
Copy after login
<span 1</span> <span <</span><span s:element </span><span name</span><span ="MinusType"</span><span ></span>
<span 2</span>      <span <</span><span s:complexType</span><span ></span>
<span 3</span>           <span <</span><span s:sequence</span><span ></span>
<span 4</span>                 <span <</span><span s:element </span><span minOccurs</span><span ="0"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="add"</span><span  type</span><span ="s:int"</span> <span /></span>
<span 5</span>                 <span <</span><span s:element </span><span minOccurs</span><span ="0"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="sub"</span><span  type</span><span ="s:int"</span> <span /></span>
<span 6</span>             <span </</span><span s:sequence</span><span ></span>
<span 7</span>       <span </</span><span s:complexType</span><span ></span>
<span 8</span> <span </</span><span s:element</span><span ></span>
Copy after login
<span 1</span> <span $ret</span> = <span $client</span>->Minus2(100,99<span );
</span><span 2</span> <span var_dump</span>(<span $ret</span><span );
</span><span 3</span> stdClass<span #</span><span 2 (2) { public $add => int(199) public $sub => int(1) }</span>
Copy after login
<span  1</span> <span class</span><span  TMinus
</span><span  2</span> <span {
</span><span  3</span>        <span var</span> <span $add</span><span ;
</span><span  4</span>        <span var</span> <span $sub</span><span ;
</span><span  5</span> <span }
</span><span  6</span> <span function</span> Minus2(<span $i</span>, <span $j</span><span )
</span><span  7</span> <span {
</span><span  8</span>       <span $minus</span> = <span new</span><span  TMinus;
</span><span  9</span>       <span $minus</span>->add = <span $i</span> + <span $j</span><span ;
</span><span 10</span>       <span $minus</span>->sub = <span $i</span> - <span $j</span><span ;
</span><span 11</span>       <span return</span> <span $minus</span><span ;
</span><span 12</span> }
Copy after login
<span 1</span> <span class</span> stdClass<span #</span><span 2 (2) { public $add => int(199) public $sub => int(1) }</span>
Copy after login
<span  1</span> <span <</span><span s:element </span><span name</span><span ="CustomType"</span><span ></span>
<span  2</span>     <span <</span><span s:complexType</span><span ></span>
<span  3</span>          <span <</span><span s:sequence</span><span ></span>
<span  4</span>               <span <</span><span s:element </span><span minOccurs</span><span ="0"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="sessionId"</span><span  type</span><span ="s:string"</span> <span /></span>
<span  5</span>               <span <</span><span s:element </span><span minOccurs</span><span ="0"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="fileSize"</span><span  type</span><span ="s:string"</span> <span /></span>
<span  6</span>           <span </</span><span s:sequence</span><span ></span>
<span  7</span>       <span </</span><span s:complexType</span><span ></span>
<span  8</span>  <span </</span><span s:element</span><span ></span>
<span  9</span>  <span <</span><span s:element </span><span name</span><span ="CustomTypeArray"</span><span ></span>
<span 10</span>       <span <</span><span s:complexType</span><span ></span>
<span 11</span>             <span <</span><span s:complexContent</span><span ></span>
<span 12</span>                   <span <</span><span s:restriction </span><span base</span><span ="soapenc:Array"</span><span ></span>
<span 13</span>                         <span <</span><span s:attribute </span><span ref</span><span ="soapenc:arrayType"</span><span  wsdl:arrayType</span><span ="tns:CustomType[]"</span><span /></span>
<span 14</span>                   <span </</span><span s:restriction</span><span ></span>
<span 15</span>            <span </</span><span s:complexContent</span><span ></span>
<span 16</span>       <span </</span><span s:complexType</span><span ></span>
<span 17</span>  <span </</span><span s:element</span><span ></span>
Copy after login
<span  1</span> <span class</span><span  CustomType
</span><span  2</span> <span {
</span><span  3</span>        <span public</span> <span $sessionId</span><span ;
</span><span  4</span>        <span public</span> <span $fileSize</span><span ;
</span><span  5</span>        <span function</span> __construct(<span $sessionID</span>, <span $fileSize</span><span )
</span><span  6</span> <span        {
</span><span  7</span>              <span $this</span>->sessionId = <span $sessionID</span><span ;
</span><span  8</span>              <span $this</span>-><span fileSize</span> = <span $fileSize</span><span ;
</span><span  9</span> <span        }
</span><span 10</span> <span }
</span><span 11</span> <span function</span><span  GetData()
</span><span 12</span> <span {
</span><span 13</span>        <span $data</span> = <span array</span><span ();
</span><span 14</span>        <span $data</span>[] = <span new</span> CustomType("123", "456"<span );
</span><span 15</span>        <span $data</span>[] = <span new</span> CustomType("789", "912"<span );
</span><span 16</span>        <span return</span> <span $data</span><span ;
</span><span 17</span> }
Copy after login
<span 1</span> <span $data</span> = <span $client</span>-><span GetData(); 
</span><span 2</span> <span foreach</span>(<span $data</span> <span as</span> <span $item</span><span ) 
</span><span 3</span> <span { 
</span><span 4</span>      <span echo</span> "<br/>".<span $item</span>->sessionId." and ".<span $item</span>-><span fileSize</span>."<br/>"<span ; 
</span><span 5</span> }
Copy after login
<span  1</span> <span <</span><span s:element </span><span name</span><span ="MyInt"</span><span ></span>
<span  2</span>      <span <</span><span s:complexType</span><span ></span>
<span  3</span>            <span <</span><span s:sequence</span><span ></span>
<span  4</span>                 <span <</span><span s:element </span><span minOccurs</span><span ="0"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="request"</span><span  type</span><span ="s:int"</span> <span /></span>
<span  5</span>            <span </</span><span s:sequence</span><span ></span>
<span  6</span>      <span </</span><span s:complexType</span><span ></span>
<span  7</span> <span </</span><span s:element</span><span ></span>
<span  8</span> <span <</span><span wsdl:message </span><span name</span><span ="MinusIn"</span><span ></span>
<span  9</span>        <span <</span><span wsdl:part </span><span name</span><span ="parameters1"</span><span  element</span><span ="tns:MyInt"</span><span /></span>
<span 10</span>        <span <</span><span wsdl:part </span><span name</span><span ="parameters2"</span><span  element</span><span ="tns:MyInt"</span><span /></span>
<span 11</span> <span </</span><span wsdl:message</span><span ></span>
Copy after login
<span  1</span> <span class</span><span  TMinus
</span><span  2</span> <span {
</span><span  3</span>        <span var</span> <span $add</span><span ;
</span><span  4</span>        <span var</span> <span $sub</span><span ;
</span><span  5</span> <span }
</span><span  6</span> <span function</span> Minus2(<span $i</span>, <span $j</span><span )
</span><span  7</span> <span {
</span><span  8</span>        <span $minus</span> = <span new</span><span  TMinus;
</span><span  9</span>        <span $minus</span>->add = <span $i</span>-><span request;
</span><span 10</span>        <span $minus</span>->sub = <span $j</span>-><span request;
</span><span 11</span>        <span return</span> <span $minus</span><span ;
</span><span 12</span> }
Copy after login
Minus2(100, 99)了,而应当修改为:
<span 1</span> <span $ret</span> = <span $client</span>->Minus2(<span array</span>("request"=>100), <span array</span>("request"=>99));
Copy after login
<span 1</span> <span $ret</span> = <span $client</span>->__call("Minus2", <span array</span>(<span array</span>("request"=>100), <span array</span>("request"=>99)));
Copy after login
<span 1</span> Error: Client, <span string</span>: SOAP-ERROR: Encoding: <span object</span> has no 'sub' property。 
Copy after login
<span  1</span> <span <</span><span s:element </span><span name</span><span ="DepartmentInfo"</span><span ></span>
<span  2</span>      <span <</span><span s:complexType</span><span ></span>
<span  3</span>             <span <</span><span s:sequence</span><span ></span>
<span  4</span>                     <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="index"</span><span  type</span><span ="s:int"</span> <span /></span>
<span  5</span>                     <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="id"</span><span  type</span><span ="s:string"</span> <span /></span>
<span  6</span>                     <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="name"</span><span  type</span><span ="s:string"</span> <span /></span>
<span  7</span>             <span </</span><span s:sequence</span><span ></span>
<span  8</span>       <span </</span><span s:complexType</span><span ></span>
<span  9</span> <span </</span><span s:element</span><span ></span>
<span 10</span> <span <</span><span s:element </span><span name</span><span ="DepartmentInfoArray"</span><span ></span>
<span 11</span>        <span <</span><span s:complexType</span><span ></span>
<span 12</span>               <span <</span><span s:complexContent</span><span ></span>
<span 13</span>                     <span <</span><span s:restriction </span><span base</span><span ="soapenc:Array"</span><span ></span>
<span 14</span>                            <span <</span><span s:attribute </span><span ref</span><span ="soapenc:arrayType"</span><span  wsdl:arrayType</span><span ="tns:DepartmentInfo[]"</span><span /></span>
<span 15</span>                     <span </</span><span s:restriction</span><span ></span>
<span 16</span>               <span </</span><span s:complexContent</span><span ></span>
<span 17</span>          <span </</span><span s:complexType</span><span ></span>
<span 18</span> <span </</span><span s:element</span><span ></span>
<span 19</span> <span <</span><span s:element </span><span name</span><span ="getAllDepartmentInfo"</span><span ></span>
<span 20</span>         <span <</span><span s:complexType</span><span ></span>
<span 21</span>               <span <</span><span s:sequence</span><span ></span>
<span 22</span>                     <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="sessionID"</span><span  type</span><span ="s:string"</span> <span /></span>
<span 23</span>               <span </</span><span s:sequence</span><span ></span>
<span 24</span>        <span </</span><span s:complexType</span><span ></span>
<span 25</span> <span </</span><span s:element</span><span ></span>
<span 26</span> <span <</span><span s:element </span><span name</span><span ="getAllDepartmentInfoResponse"</span><span ></span>
<span 27</span>        <span <</span><span s:complexType</span><span ></span>
<span 28</span>               <span <</span><span s:sequence</span><span ></span>
<span 29</span>                  <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="errorCode"</span><span  type</span><span ="s:int"</span> <span /></span>
<span 30</span>                  <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="aDepartmentInfo"</span><span  type</span><span ="tns:DepartmentInfoArray"</span> <span /></span>
<span 31</span>               <span </</span><span s:sequence</span><span ></span>
<span 32</span>        <span </</span><span s:complexType</span><span ></span>
<span 33</span> <span </</span><span s:element</span><span ></span>
Copy after login
<span  1</span> <span <</span><span s:complexType </span><span name</span><span ="DepartmentInfo"</span><span ></span>
<span  2</span>       <span <</span><span s:sequence</span><span ></span>
<span  3</span>              <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="index"</span><span  type</span><span ="s:int"</span> <span /></span>
<span  4</span>              <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="id"</span><span  type</span><span ="s:string"</span> <span /></span>
<span  5</span>              <span <</span><span s:element </span><span minOccurs</span><span ="1"</span><span  maxOccurs</span><span ="1"</span><span  name</span><span ="name"</span><span  type</span><span ="s:string"</span> <span /></span>
<span  6</span>        <span </</span><span s:sequence</span><span ></span>
<span  7</span> <span </</span><span s:complexType</span><span ></span>
<span  8</span> <span <</span><span s:complexType </span><span name</span><span ="DepartmentInfoArray"</span><span ></span>
<span  9</span>       <span <</span><span s:complexContent</span><span ></span>
<span 10</span>              <span <</span><span s:restriction </span><span base</span><span ="soapenc:Array"</span><span ></span>
<span 11</span>                     <span <</span><span s:attribute </span><span ref</span><span ="soapenc:arrayType"</span><span  wsdl:arrayType</span><span ="tns:DepartmentInfo[]"</span><span /></span>
<span 12</span>               <span </</span><span s:restriction</span><span ></span>
<span 13</span>       <span </</span><span s:complexContent</span><span ></span>
<span 14</span> <span </</span><span s:complexType</span><span ></span>
Copy after login

 

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template