Clientprotocolexception when attempting to submit a request to soap wsdlrequest through Java setting user name and password

My goal is to create a soap UI project with a given WSDL URL, save it and send all requests through Java methods I received org apache. http. client. ClientProtocolException ….. Caused by the following reasons: org apache. http. Protocolexception: when I try to submit a request by setting the user name and password of the operation, an error has occurred in the content length header Find my java method to send the request

public void runSoap() throws Exception
{
        String projectFile = "SoapUIProjects/TestProjectA-soapui-project.xml";
    SoapUI.setSoapUICore(new StandaloneSoapUICore(true));
    WsdlProject project = new WsdlProject(projectFile);

    int c = project.getInterfaceCount();
    System.out.println("The interface count   ="+c);

    for(int i=0;i<c;i++)
    {
        WsdlInterface wsdl = (WsdlInterface) project.getInterfaceAt(i);
        String soapVersion = wsdl.getSoapVersion().toString();
        int opc = wsdl.getOperationCount();
        String result="";

        for(int j=0;j<opc;j++)
        {
            WsdlOperation op = wsdl.getOperationAt(j);
                String opName = op.getName();
                System.out.println("OPERATION:"+opName);

                WsdlRequest req = op.getRequestByName("Req_"+soapVersion+"_"+opName);

                //Assigning correct u/p to an operation: Generate
                if(opName.equals("Generate"))
                {
                    System.out.println("The operation is Generate.");
                    req.setUsername("u1");//Setting username
                    req.setPassword("u1");//Setting password
               }

               WsdlSubmitContext wsdlSubmitContext = new WsdlSubmitContext(req);
               WsdlSubmit<?> submit = (WsdlSubmit<?>) req.submit(wsdlSubmitContext,false);
               Response response = submit.getResponse();
               result = response.getContentAsString();
               System.out.println("The result ="+result);
        }
    }
}

Please also refer to the attached figure Can someone tell me what went wrong and how to solve it?

Solution

I got the answer to my question

Through this, the request is sent, and I have no exception

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>