org.xml.sax.SAXException:错误的信封标签:html

时间:2015-02-06 15:30:46

标签: java web-services axis

我正在尝试调用Web服务以获得响应。我正在使用基于轴的SOAP webservice.But当我运行代码时它给了我一个sasxexception。 这是我的java代码:

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;

    public class ClientTest {

      public static void main(String [] args)
      {
            String request = "<Request onErrorAbort=\"yes\">\n"+
            "<Service name=\""+service+"\" operation=\""+operation+"\" id=\"11500\">\n"+
                "<Parameter name=\"ApplicationExterieureIdentifiant\">"+applicationExterieureIdentifiant+"</Parameter>\n"+
                "<Parameter name=\"ApplicationExterieureLibelle\">"+applicationExterieureLibelle+"</Parameter>\n"+
                "<Parameter name=\"ActionTypeLibelle\">"+actionTypeLibelle+"</Parameter>\n"+
                "<Parameter name=\"ActionIdentifiant\">"+actionIdentifiant+"</Parameter>\n"+
                "<Parameter name=\"ActionLibelle\">"+actionLibelle+"</Parameter>\n"+
                "<Parameter name=\"PatientIdentifiant\">"+patientIdentifiant+"</Parameter>\n"+
                "<Parameter name=\"PatientIPP\">"+patientIPP+"</Parameter>\n"+
                "<Parameter name=\"VenueIdentifiant\">"+venueIdentifiant+"</Parameter>\n"+
                "<Parameter name=\"VenueNumero\">"+venueNumero+"</Parameter>\n"+
                "<Parameter name=\"InterventionIdentifiantExterieur\">"+interventionIdentifiantExterieur+"</Parameter>\n"+
                "<Parameter name=\"PrescripteurIdentifiant\">"+prescripteurIdentifiant+"</Parameter>\n"+
                "<Parameter name=\"PrescripteurCompteUtilisateur\">"+prescripteurCompteUtilisateur+"</Parameter>\n"+
                "<Parameter name=\"PrescripteurNomPrenom\">"+prescripteurNomPrenom+"</Parameter>\n"+
                "<Parameter name=\"CreateurIdentifiant\">"+createurIdentifiant+"</Parameter>\n"+
                "<Parameter name=\"CreateurCompteUtilisateur\">"+createurCompteUtilisateur+"</Parameter>\n"+
                "<Parameter name=\"InterventionMetiers\">"+interventionMetiers+"</Parameter>\n"+
                "<Parameter name=\"InterventionPlanificationDate\">"+interventionPlanificationDate+"</Parameter>\n"+
                "<Parameter name=\"InterventionPlanificationDansJournee\">"+interventionPlanificationDansJournee+"</Parameter>\n"+
                "<Parameter name=\"InterventionPlanificationAuBesoin\">"+interventionPlanificationAuBesoin+"</Parameter>\n"+
                "<Parameter name=\"InterventionPlanificationAuBesoinCondition\">"+interventionPlanificationAuBesoinCondition+"</Parameter>\n"+
                "<Parameter name=\"InterventionPlanificationDuree\">"+interventionPlanificationDuree+"</Parameter>\n"+
                "<Parameter name=\"InterventionPlanificationCommentaire\">"+interventionPlanificationCommentaire+"</Parameter>\n"+
                "<Parameter name=\"InterventionPriorite\">"+interventionPriorite+"</Parameter>\n"+
                "<Parameter name=\"InterventionURLExterieure\">"+interventionURLExterieure.replaceAll("&", "&amp;")+"</Parameter>\n"+
                "<Parameter name=\"InterventionURLExterieureParametres\">"+interventionURLExterieureParametres.replaceAll("&", "&amp;")+"</Parameter>\n"+
            "</Service>\n"+
        "</Request>\n";

             callService(request, args[0]);
      }

       public static void callService(String request, String urlDest){
           try {

                  /*
                   * urlDest the URL of the destination Web Service     
                   */


                  /*
                   * create a new Service instance
                   */  
                  Service serviceInstance = new Service();

                  /*
                   * ask the Service to create a call 
                   */
                  Call   call  = (Call) serviceInstance.createCall();


                  /*
                   *  We tell the Call that this URL is the target endpoint to connect to
                   */
                  call.setTargetEndpointAddress(new java.net.URL(urlDest));

                  /*
                   * The QName uses the webservice namespace used in the WSDL file 
                   * and the name of the method on the webservice that we want to execute: returnResponse
                   */

                  call.setOperationName( new QName("http://www.crih-des-alpes.com/PcfwkWebService", "ExecuteString") );

                  /*
                   * we tell the call that we have two input parameters 
                   * -- a String followed by another String --
                   *  and that we expect a String to be returned to us.
                   */

                  call.addParameter( "arg0", XMLType.XSD_STRING, ParameterMode.IN);  
                  call.addParameter( "arg1", XMLType.XSD_STRING, ParameterMode.IN);    
                  call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING );

                  System.out.println("before invoke: "+call.toString());
                  /*
                   * we invoke the Web Service call, passing it our parameters,
                   *  wrapping in an Object array, and capture the response
                   */
                  String response = (String) call.invoke( new Object[] {request ,"CNET_VA_DPLAN_API" } );      
                  System.out.println("The result : " + response);
                 // createFileResult(ret);
                } catch (Exception e) {
                  System.err.println(e.toString());
                }
       }

    }

任何人都可以帮助我如何解决此异常?

1 个答案:

答案 0 :(得分:0)

编写soap客户端的标准方法涉及从wsdl文件生成客户端

wsimport -keep -verbose http://com.company/ws/server?wsdl

用字符串编码所有东西都可以,但从长远来看,你真的会迷失方向。