预期的异常是什么:START_TAG'是指在调用Web服务时出现的异常

时间:2014-06-23 13:27:04

标签: java android web-services wsdl

我使用以下代码在android中调用web服务:

public class Main {

    private static final String NAMESPACE = "urn:sap-com:document:sap:rfc:functions";
    private static String URL = "http://hr_develop:unrwa2013@10.130.105.8:8000/sap/bc/srt/wsdl/flv_10002A111AD1/srvc_url/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding?sap-client=520";
    private static final String METHOD_NAME = "Z_TM_ETM_GET_EMPL_HOLIDAYS";
    private static final String SOAP_ACTION = "urn:sap-com:document:sap:rfc:functions:ztm_ws_get_emp_holidays:Z_TM_ETM_GET_EMPL_HOLIDAYSRequest";



    // private static final String SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME;

    public static void main(String args[]) {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        PropertyInfo arg1 = new PropertyInfo();
        arg1.name = "PI_PERNR";
        arg1.type = PropertyInfo.STRING_CLASS;
        arg1.setValue("10101010");
        request.addProperty(arg1);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);

            SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope
                    .getResponse();

            System.out.println(resultsRequestSOAP.toString());

        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());

        }
    }
}

但发生异常:

expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@1:6 in java.io.InputStreamReader@9f436f5) 

修改

WSDL文件:

<wsdl:definitions targetNamespace="urn:sap-com:document:sap:rfc:functions">
  <wsdl:documentation>
    <sidl:sidl/>
  </wsdl:documentation>
  <wsp:UsingPolicy wsdl:required="true"/>
  <wsp:Policy wsu:Id="BN__binding">
    <wsp:ExactlyOne>
      <wsp:All>
        <sapattahnd:Enabled>false</sapattahnd:Enabled>
        <saptrnbnd:OptimizedMimeSerialization wsp:Optional="true"/>
        <wsaw:UsingAddressing wsp:Optional="true"/>
        <wsp:All>
          <sp:TransportBinding>
            <wsp:Policy>
              <sp:TransportToken>
                <wsp:Policy>
                  <sp:HttpsToken>
                    <wsp:Policy>
                      <sp:HttpBasicAuthentication/>
                    </wsp:Policy>
                  </sp:HttpsToken>
                </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
                <wsp:Policy>
                  <sp:Basic128Rsa15/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
            </wsp:Policy>
          </sp:TransportBinding>
        </wsp:All>
      </wsp:All>
      <wsp:All>
        <sapattahnd:Enabled>false</sapattahnd:Enabled>
        <saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/>
        <wsaw:UsingAddressing wsp:Optional="true"/>
        <wsp:All>
          <sp:TransportBinding>
            <wsp:Policy>
              <sp:TransportToken>
                <wsp:Policy>
                  <sp:HttpsToken>
                    <wsp:Policy>
                      <sp:HttpBasicAuthentication/>
                    </wsp:Policy>
                  </sp:HttpsToken>
                </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
                <wsp:Policy>
                  <sp:Basic128Rsa15/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
            </wsp:Policy>
          </sp:TransportBinding>
        </wsp:All>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="BN__binding_soap12">
    <wsp:ExactlyOne>
      <wsp:All>
        <sapattahnd:Enabled>false</sapattahnd:Enabled>
        <saptrnbnd:OptimizedMimeSerialization wsp:Optional="true"/>
        <wsaw:UsingAddressing wsp:Optional="true"/>
        <wsp:All>
          <sp:TransportBinding>
            <wsp:Policy>
              <sp:TransportToken>
                <wsp:Policy>
                  <sp:HttpsToken>
                    <wsp:Policy>
                      <sp:HttpBasicAuthentication/>
                    </wsp:Policy>
                  </sp:HttpsToken>
                </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
                <wsp:Policy>
                  <sp:Basic128Rsa15/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
            </wsp:Policy>
          </sp:TransportBinding>
        </wsp:All>
      </wsp:All>
      <wsp:All>
        <sapattahnd:Enabled>false</sapattahnd:Enabled>
        <saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/>
        <wsaw:UsingAddressing wsp:Optional="true"/>
        <wsp:All>
          <sp:TransportBinding>
            <wsp:Policy>
              <sp:TransportToken>
                <wsp:Policy>
                  <sp:HttpsToken>
                    <wsp:Policy>
                      <sp:HttpBasicAuthentication/>
                    </wsp:Policy>
                  </sp:HttpsToken>
                </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
                <wsp:Policy>
                  <sp:Basic128Rsa15/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
            </wsp:Policy>
          </sp:TransportBinding>
        </wsp:All>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="IF__ztm_ws_get_emp_holidays">
    <wsp:ExactlyOne>
      <wsp:All>
        <sapsession:Session>
          <sapsession:enableSession>false</sapsession:enableSession>
        </sapsession:Session>
        <sapcentraladmin:CentralAdministration wsp:Optional="true">
          <sapcentraladmin:BusinessApplicationID>005056AC6E191ED3979A90345DADF406</sapcentraladmin:BusinessApplicationID>
        </sapcentraladmin:CentralAdministration>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="OP__Z_TM_ETM_GET_EMPL_HOLIDAYS">
    <wsp:ExactlyOne>
      <wsp:All>
        <saptrhnw05:required>no</saptrhnw05:required>
        <sapcomhnd:enableCommit>false</sapcomhnd:enableCommit>
        <sapblock:enableBlocking>true</sapblock:enableBlocking>
        <saprmnw05:enableWSRM>false</saprmnw05:enableWSRM>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types>
    <xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
      <xsd:simpleType name="char1">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="1"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char10">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="10"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char20">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="20"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char220">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="220"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char30">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="30"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char32">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="32"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char40">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="40"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char50">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="50"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="date10">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="10"/>
          <xsd:pattern value="\d\d\d\d-\d\d-\d\d"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="numeric3">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="3"/>
          <xsd:pattern value="\d*"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="numeric6">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="6"/>
          <xsd:pattern value="\d*"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="numeric8">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="8"/>
          <xsd:pattern value="\d*"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:complexType name="ZTMSHOLIDAYS">
        <xsd:sequence>
          <xsd:element name="DATE" type="tns:date10"/>
          <xsd:element name="DESCRIPTION" type="tns:char40"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="BAPIRET2">
        <xsd:sequence>
          <xsd:element name="TYPE" type="tns:char1"/>
          <xsd:element name="ID" type="tns:char20"/>
          <xsd:element name="NUMBER" type="tns:numeric3"/>
          <xsd:element name="MESSAGE" type="tns:char220"/>
          <xsd:element name="LOG_NO" type="tns:char20"/>
          <xsd:element name="LOG_MSG_NO" type="tns:numeric6"/>
          <xsd:element name="MESSAGE_V1" type="tns:char50"/>
          <xsd:element name="MESSAGE_V2" type="tns:char50"/>
          <xsd:element name="MESSAGE_V3" type="tns:char50"/>
          <xsd:element name="MESSAGE_V4" type="tns:char50"/>
          <xsd:element name="PARAMETER" type="tns:char32"/>
          <xsd:element name="ROW" type="xsd:int"/>
          <xsd:element name="FIELD" type="tns:char30"/>
          <xsd:element name="SYSTEM" type="tns:char10"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZTMTT_HOLIDAYS">
        <xsd:sequence>
          <xsd:element name="item" type="tns:ZTMSHOLIDAYS" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:element name="Z_TM_ETM_GET_EMPL_HOLIDAYS">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="PI_PERNR" type="tns:numeric8"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Z_TM_ETM_GET_EMPL_HOLIDAYSResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="PE_I_HOLIDAYS" type="tns:ZTMTT_HOLIDAYS"/>
            <xsd:element name="PE_MESSAGE" type="tns:BAPIRET2"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="Z_TM_ETM_GET_EMPL_HOLIDAYS">
    <wsdl:part name="parameters" element="tns:Z_TM_ETM_GET_EMPL_HOLIDAYS"/>
  </wsdl:message>
  <wsdl:message name="Z_TM_ETM_GET_EMPL_HOLIDAYSResponse">
    <wsdl:part name="parameter" element="tns:Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"/>
  </wsdl:message>
  <wsdl:portType name="ztm_ws_get_emp_holidays">
    <wsp:Policy>
      <wsp:PolicyReference URI="#IF__ztm_ws_get_emp_holidays"/>
    </wsp:Policy>
    <wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS">
      <wsp:Policy>
        <wsp:PolicyReference URI="#OP__Z_TM_ETM_GET_EMPL_HOLIDAYS"/>
      </wsp:Policy>
      <wsdl:input message="tns:Z_TM_ETM_GET_EMPL_HOLIDAYS"/>
      <wsdl:output message="tns:Z_TM_ETM_GET_EMPL_HOLIDAYSResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="binding" type="tns:ztm_ws_get_emp_holidays">
    <wsp:Policy>
      <wsp:PolicyReference URI="#BN__binding"/>
    </wsp:Policy>
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS">
      <soap:operation soapAction="urn:sap-com:document:sap:rfc:functions:ztm_ws_get_emp_holidays:Z_TM_ETM_GET_EMPL_HOLIDAYSRequest" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="binding_soap12" type="tns:ztm_ws_get_emp_holidays">
    <wsp:Policy>
      <wsp:PolicyReference URI="#BN__binding_soap12"/>
    </wsp:Policy>
    <wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="Z_TM_ETM_GET_EMPL_HOLIDAYS">
      <wsoap12:operation soapAction="urn:sap-com:document:sap:rfc:functions:ztm_ws_get_emp_holidays:Z_TM_ETM_GET_EMPL_HOLIDAYSRequest" style="document"/>
      <wsdl:input>
        <wsoap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <wsoap12:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="OfficialHolidays">
    <wsdl:port name="binding" binding="tns:binding">
      <soap:address location="http://unrwa-red-71.unrwa.org:8000/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding"/>
    </wsdl:port>
    <wsdl:port name="binding_soap12" binding="tns:binding_soap12">
      <wsoap12:address location="http://unrwa-red-71.unrwa.org:8000/sap/bc/srt/rfc/sap/ztm_ws_get_emp_holidays/520/officialholidays/binding"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

1 个答案:

答案 0 :(得分:0)

表示Web Service客户端需要SOAP信封响应,但接收HTML页面。您呼叫的服务可能无法使用。