简体   繁体   中英

SOAP authentication with PHP WSDL

I have looked at several related topics, but none solved my wsdl/soap/php issue.

My header looks like this;

<?xml version="1.0" encoding="ISO-8859-1"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="http://"> 
    <SOAP-ENV:Header> 
        <ns:authentication> 
            <username>username</username> 
            <password>password</password> 
        </ns:authentication> 
    </SOAP-ENV:Header> 
</SOAP-ENV:Envelope> 

I am not able to succesfully connect. I've tried sample codes but none of them worked.

Any help is appreciated.

Additional authentication info:

<xsd:complexType>
           <xsd:all>
              <xsd:element name="username" nillable="false" minOccurs="1" maxOccurs="1">
                 <xsd:annotation>
                    <xsd:documentation>Username for authenticatie</xsd:documentation>
                 </xsd:annotation>
                 <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                       <xsd:maxLength value="4000"/>
                    </xsd:restriction>
                 </xsd:simpleType>
              </xsd:element>
              <xsd:element name="password" nillable="false" minOccurs="1" maxOccurs="1">
                 <xsd:annotation>
                    <xsd:documentation>Password for authentication</xsd:documentation>
                 </xsd:annotation>
                 <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                       <xsd:maxLength value="4000"/>
                    </xsd:restriction>
                 </xsd:simpleType>
              </xsd:element>
           </xsd:all>
        </xsd:complexType>

A full working request looks like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:zone="http://">
   <soapenv:Header>
       <zone:authentication>
          <!--You may enter the following 2 items in any order-->
          <username>myusername</username>
          <password>mypassword</password>
       </zone:authentication>
   </soapenv:Header>
   <soapenv:Body>
       <zone:searchSubscriptionRequest>
          <!--You may enter the following 2 items in any order-->
          <requestTag>test</requestTag>
          <zipcode>000 AB</zipcode>
       </zone:searchSubscriptionRequest>
  </soapenv:Body>

It's not using standard <SOAP-ENV:Header> authentication, instead username and password are regular variables inside <SOAP-ENV:Body> .

The snippet is out of context, so I can't tell you how to set them, but you can use some WSDL to PHP code generator to get PHP classes for you to discover.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM