ksoap2复杂参数-SoapFault-故障代码:'soap:Client'故障字符串:

时间:2018-07-20 09:05:35

标签: java android soap wsdl ksoap2

我正在尝试将Webservice与KSoap2一起使用,但我不断收到以下错误消息:

> 07-20 10:00:06.177 24213-24371/com.ablinfo.mweb W/System.err: SoapFault - faultcode: 'soap:Client' faultstring: 'Error processing input' faultactor: 'null' detail: org.kxml2.kdom.Node@c689660
07-20 10:00:06.185 24213-24371/com.ablinfo.mweb W/System.err:     at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:136)
07-20 10:00:06.186 24213-24371/com.ablinfo.mweb W/System.err:     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
        at org.ksoap2.transport.Transport.parseResponse(Transport.java:129)
        at org.ksoap2.transport.HttpTransportSE.parseResponse(HttpTransportSE.java:301)
        at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:274)
        at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118)
        at com.ablinfo.mweb.service.WebServiceCall.callWSThreadSoapPrimitive(WebServiceCall.java:120)
        at com.ablinfo.mweb.service.GetArticleTask.doInBackground(GetArticleTask.java:36)
        at com.ablinfo.mweb.service.GetArticleTask.doInBackground(GetArticleTask.java:11)
        at android.os.AsyncTask$2.call(AsyncTask.java:295)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)

这是我的代码:     公共类WebServiceCall {

private static final String TAG = WebServiceCall.class.getSimpleName();

private static TrustManager[] trustManagers;

public static String callWSThreadSoapPrimitive(String strURL, String strSoapAction, SoapObject request) {
    try {
        StringBuffer result = null;

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.addMapping(ConstantString.NAME_SPACE,"SQLMSGIN-GETLOGIN_IN-CIN",new GETLOGIN_INType().getClass());
        SoapObject __soapReq = new SoapObject(ConstantString.NAME_SPACE, "CGETLOGIN_OUT-GETLOGINInput");

        GETLOGIN_INType_GETLOGIN_IN getlogin_InType_GetLogin_in=new GETLOGIN_INType_GETLOGIN_IN();

        getlogin_InType_GetLogin_in.setProperty(0,"login");
        getlogin_InType_GetLogin_in.setProperty(1,"password");


        GETLOGIN_INType getLogin_InType=new GETLOGIN_INType();
        getLogin_InType.setProperty(0,getlogin_InType_GetLogin_in);

        PropertyInfo __info=null;
        __info = new PropertyInfo();
        __info.namespace=ConstantString.NAME_SPACE;
        __info.name="SQLMSGIN-GETLOGIN_IN-CIN";
        __info.type=GETLOGIN_INType.class;
        __info.setValue(getLogin_InType);
        __soapReq.addProperty(__info);

        envelope.setOutputSoapObject(__soapReq);

        envelope.dotNet = true;
        // certificat SSL
        allowAllSSL();

        HttpTransportSE ht = new HttpTransportSE(strURL);

        List<HeaderProperty> llstHeadersProperty = new ArrayList<>();
        llstHeadersProperty.add(new HeaderProperty("Authorization", "Basic " + Base64.encode("user:pass".getBytes())));

        ht.debug = true;
        ht.call(strSoapAction, envelope,llstHeadersProperty);
        Log.d(TAG,"requestdump:"+ht.requestDump);
        Log.d(TAG,"responseDump:"+ht.responseDump);
        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            result = new StringBuffer(response.toString());


        Log.i(TAG, "result: " + result.toString());
        return result.toString();

    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }


}

我的GETLOGIN_INType_GETLOGIN_IN类:

    public class GETLOGIN_INType_GETLOGIN_IN extends AttributeContainer implements KvmSerializable
{


    public String LOGIN;

    public String PASSWORD;


    @Override
    public java.lang.Object getProperty(int propertyIndex) {
           if(propertyIndex==0)
        {
            return LOGIN;
        }
        if(propertyIndex==1)
        {
            return PASSWORD;
        }
        return null;
    }


    @Override
    public int getPropertyCount() {
        return 2;
    }

    @Override
    public void getPropertyInfo(int propertyIndex, @SuppressWarnings("rawtypes") Hashtable arg1, PropertyInfo info)
    {
        if(propertyIndex==0)
        {
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "LOGIN";
            info.namespace= ConstantString.NAME_SPACE;
        }
        if(propertyIndex==1)
        {
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "PASSWORD";
            info.namespace= ConstantString.NAME_SPACE;
        }
    }

    @Override
    public void setProperty(int arg0, java.lang.Object arg1)
    {
        switch(arg0)
        {
            case 0:
                LOGIN =  (String)arg1;
                break;
            case 1:
                PASSWORD =  (String)arg1;
                break;
            default:
                break;
        }
    }


}

我的GETLOGIN_INType类

public class GETLOGIN_INType extends AttributeContainer implements KvmSerializable
{
    public GETLOGIN_INType_GETLOGIN_IN GETLOGIN_IN;

    @Override
    public java.lang.Object getProperty(int propertyIndex) {

    if(propertyIndex==0)
    {
        return GETLOGIN_IN;
    }
    return null;
}


    @Override
    public int getPropertyCount() {
    return 1;
}

    @Override
    public void getPropertyInfo(int propertyIndex, @SuppressWarnings("rawtypes") Hashtable arg1, PropertyInfo info)
    {
        if(propertyIndex==0)
        {
            info.type = GETLOGIN_INType_GETLOGIN_IN.class;
            info.name = "GETLOGIN_IN";
            info.namespace= ConstantString.NAME_SPACE;
        }
    }

    @Override
    public void setProperty(int arg0, java.lang.Object arg1)
    {
        if(arg0==0)
        {
            GETLOGIN_IN= (GETLOGIN_INType_GETLOGIN_IN) arg1;
        }
    }

}

我的WSDL:

      <?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://xmlns.oracle.com/orawsv/ABL/WSS_MWEB_LOGIN/GETLOGIN" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.oracle.com/orawsv/ABL/WSS_MWEB_LOGIN/GETLOGIN" name="GETLOGIN">
   <types>
      <xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/ABL/WSS_MWEB_LOGIN/GETLOGIN" elementFormDefault="qualified">
         <xsd:element name="CGETLOGIN_OUT-GETLOGINInput">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element type="tns:GETLOGIN_INType" name="SQLMSGIN-GETLOGIN_IN-CIN" />
               </xsd:sequence>
            </xsd:complexType>
         </xsd:element>
         <xsd:element name="GETLOGINOutput">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element type="tns:GETLOGIN_OUTType" name="RETURN" />
               </xsd:sequence>
            </xsd:complexType>
         </xsd:element>
         <xsd:complexType name="GETLOGIN_INType">
            <xsd:sequence>
               <xsd:element name="GETLOGIN_IN">
                  <xsd:complexType>
                     <xsd:sequence>
                        <xsd:element name="LOGIN">
                           <xsd:simpleType>
                              <xsd:restriction base="xsd:string">
                                 <xsd:maxLength value="100" />
                              </xsd:restriction>
                           </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="PASSWORD">
                           <xsd:simpleType>
                              <xsd:restriction base="xsd:string">
                                 <xsd:maxLength value="20" />
                              </xsd:restriction>
                           </xsd:simpleType>
                        </xsd:element>
                     </xsd:sequence>
                  </xsd:complexType>
               </xsd:element>
            </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="GETLOGIN_OUTType">
            <xsd:sequence>
               <xsd:element name="GETLOGIN_OUT">
                  <xsd:complexType>
                     <xsd:sequence>
                        <xsd:element name="LOGIN">
                           <xsd:simpleType>
                              <xsd:restriction base="xsd:string">
                                 <xsd:maxLength value="100" />
                              </xsd:restriction>
                           </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="STE">
                           <xsd:simpleType>
                              <xsd:restriction base="xsd:string">
                                 <xsd:maxLength value="3" />
                              </xsd:restriction>
                           </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="CLI">
                           <xsd:simpleType>
                              <xsd:restriction base="xsd:string">
                                 <xsd:maxLength value="20" />
                              </xsd:restriction>
                           </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="ADMN">
                           <xsd:simpleType>
                              <xsd:restriction base="xsd:string">
                                 <xsd:maxLength value="1" />
                              </xsd:restriction>
                           </xsd:simpleType>
                        </xsd:element>
                        <xsd:element type="xsd:double" name="CNXERR" />
                        <xsd:element name="ERREUR_LIST">
                           <xsd:complexType>
                              <xsd:sequence>
                                 <xsd:element type="tns:SQLERREUR_IntType" name="SQLERREUR" minOccurs="0" maxOccurs="unbounded" />
                              </xsd:sequence>
                           </xsd:complexType>
                        </xsd:element>
                     </xsd:sequence>
                  </xsd:complexType>
               </xsd:element>
            </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="SQLERREUR_IntType">
            <xsd:sequence>
               <xsd:element name="ERR_ID">
                  <xsd:simpleType>
                     <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="5" />
                     </xsd:restriction>
                  </xsd:simpleType>
               </xsd:element>
               <xsd:element name="ERR_LIGNE">
                  <xsd:simpleType>
                     <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="5" />
                     </xsd:restriction>
                  </xsd:simpleType>
               </xsd:element>
               <xsd:element name="ERR_CODE">
                  <xsd:simpleType>
                     <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="10" />
                     </xsd:restriction>
                  </xsd:simpleType>
               </xsd:element>
               <xsd:element name="ERR_MSG">
                  <xsd:simpleType>
                     <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="512" />
                     </xsd:restriction>
                  </xsd:simpleType>
               </xsd:element>
               <xsd:element name="ERR_NIV">
                  <xsd:simpleType>
                     <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="1" />
                     </xsd:restriction>
                  </xsd:simpleType>
               </xsd:element>
            </xsd:sequence>
         </xsd:complexType>
      </xsd:schema>
   </types>
   <message name="GETLOGINInputMessage">
      <part name="parameters" element="tns:CGETLOGIN_OUT-GETLOGINInput" />
   </message>
   <message name="GETLOGINOutputMessage">
      <part name="parameters" element="tns:GETLOGINOutput" />
   </message>
   <portType name="GETLOGINPortType">
      <operation name="GETLOGIN">
         <input message="tns:GETLOGINInputMessage" />
         <output message="tns:GETLOGINOutputMessage" />
      </operation>
   </portType>
   <binding type="tns:GETLOGINPortType" name="GETLOGINBinding">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
      <operation name="GETLOGIN">
         <soap:operation soapAction="GETLOGIN" />
         <input>
            <soap:body use="literal" parts="parameters" />
         </input>
         <output>
            <soap:body use="literal" parts="parameters" />
         </output>
      </operation>
   </binding>
   <service name="GETLOGINService">
      <documentation>Oracle Web Service</documentation>
      <port name="GETLOGINPort" binding="tns:GETLOGINBinding">
         <soap:address location="https://xxx.xxx.xx.xxx:1443/orawsv/ABL/WSS_MWEB_LOGIN/GETLOGIN" />
      </port>
   </service>
</definitions>

我无法正确设置请求肥皂。我认为,我必须正确使用PropertyInfo,但是我不能使用此wsdl来做到这一点。你能帮我吗?

更新:

有关信息,请参阅我的请求转储:

<?xml version="1.0" encoding="UTF-8"?>
<v:Envelope xmlns:v="http://schemas.xmlsoap.org/soap/envelope/" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
   <v:Header />
   <v:Body>
      <CGETLOGIN_OUT-GETLOGINInput xmlns="http://xmlns.oracle.com/orawsv/ABL/WSS_MWEB_LOGIN/GETLOGIN" id="o0" c:root="1">
         <n0:SQLMSGIN-GETLOGIN_IN-CIN xmlns:n0="http://xmlns.oracle.com/orawsv/ABL/WSS_MWEB_LOGIN/GETLOGIN" i:type="n0:SQLMSGIN-GETLOGIN_IN-CIN">
            <n0:GETLOGIN_IN i:type="d:anyType">
               <n0:LOGIN i:type="d:string">login</n0:LOGIN>
               <n0:PASSWORD i:type="d:string">password</n0:PASSWORD>
            </n0:GETLOGIN_IN>
         </n0:SQLMSGIN-GETLOGIN_IN-CIN>
      </CGETLOGIN_OUT-GETLOGINInput>
   </v:Body>
</v:Envelope>

使用SoapUI我有以下示例请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:get="http://xmlns.oracle.com/orawsv/ABL/WSS_MWEB_LOGIN/GETLOGIN">
   <soapenv:Header/>
   <soapenv:Body>
      <get:CGETLOGIN_OUT-GETLOGINInput>
         <get:SQLMSGIN-GETLOGIN_IN-CIN>
            <get:GETLOGIN_IN>
               <get:LOGIN>login</get:LOGIN>
               <get:PASSWORD>password</get:PASSWORD>
            </get:GETLOGIN_IN>
         </get:SQLMSGIN-GETLOGIN_IN-CIN>
      </get:CGETLOGIN_OUT-GETLOGINInput>
   </soapenv:Body>
</soapenv:Envelope>

我的回复转储:

<?xml version="1.0" ?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
     <soap:Body>
       <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Error processing input</faultstring>
         <detail>
          <OracleErrors xmlns="http://xmlns.oracle.com/orawsv/faults">
           <OracleError>
            <ErrorNumber>ORA-19031</ErrorNumber>
            <Message><![CDATA[XML element or attribute @type does not match any in type ABL.GETLOGIN_IN]]></Message>
          </OracleError>
          </OracleErrors>
         </detail>
       </soap:Fault>
     </soap:Body>
    </soap:Envelope>

0 个答案:

没有答案