Web服务请求在Soap UI中得到正确的服务,而不是在Java程序中

Web服务请求在Soap UI中得到正确的服务,而不是在Java程序中,java,web-services,proxy,soapui,Java,Web Services,Proxy,Soapui,我们正在尝试使用web服务识别图像中的文本:www.ocrwebservice.com 它使用Soap UI得到正确的服务,我们得到可识别的文本作为响应: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xm

我们正在尝试使用web服务识别图像中的文本:www.ocrwebservice.com 它使用Soap UI得到正确的服务,我们得到可识别的文本作为响应:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope">

<wsa:Action>http://stockservice.contoso.com/wse/samples/2005/10/OCRWebServiceRecognizeResponse</wsa:Action>
      <wsa:MessageID>urn:uuid:14db681a-8f8b-4fb6-8de3-a5a122e07a43</wsa:MessageID>
      <wsa:RelatesTo>urn:uuid:ca0891c2-6838-45b0-8691-37909c69cdd9</wsa:RelatesTo>
      <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
      <wsse:Security>
         <wsu:Timestamp wsu:Id="Timestamp-16f0eade-c981-400b-ac8e-1fe49ed1358e">
            <wsu:Created>2012-01-24T11:31:46Z</wsu:Created>
            <wsu:Expires>2012-01-24T11:36:46Z</wsu:Expires>
         </wsu:Timestamp>
      </wsse:Security>
   </env:Header>
   <soap:Body>
      <OCRWebServiceRecognizeResponse xmlns="http://stockservice.contoso.com/wse/samples/2005/10">
         <OCRWSResponse>
            <ocrText/>
            <errorMessage>Recognized Words not available</errorMessage>
            <ocrWSWords/>
         </OCRWSResponse>
      </OCRWebServiceRecognizeResponse>
   </soap:Body>
</soap:Envelope>
在我们的组织中,有一个防火墙。并且需要代理来发送请求。
这里可能出了什么问题?

您是否在SOAP UI请求中使用任何凭据?错误提示您的服务器需要提供用户名密码。soap使用的身份验证是什么?WS-Security?另外您能告诉我们您是如何访问和使用它的吗?是的,使用web服务需要用户名和许可证代码。这是“字符串请求”的一部分。如果没有这一点,请求甚至在SOAP UI中也无法工作。SOAP UI在内部使用WS-security。查看我们认为最有可能是Wsa的响应。我们再次编辑了该问题以显示SOAP UI响应。您好RoiG,我希望您将此评论作为答案发布,因为通过对WS-Security的敏锐关注,问题得以解决。请你考虑把你的评论作为回答。
<errorMessage>Invalid user name</errorMessage>
public class CallingWS
{
    /**
     * @param args
     */
    public static void main(String[] args)
    {
        StringBuffer _buf = new StringBuffer();
        Vector respElements = new Vector();

        try
        {
            System.getProperties().put("http.proxyHost", "proxy.OurOrganisation.com");
            System.getProperties().put("http.proxyPort", "1234");
            String endpointURL = "http://www.ocrwebservice.com/services/OCRWebService.asmx?WSDL";
            System.out.println((new StringBuilder()).append("endpointURL: ").append(endpointURL).toString());
            Service service = new Service();
            Call call = (Call)service.createCall();
            call.setTargetEndpointAddress(new URL(endpointURL));
            SOAPBodyElement requestElements[] = new SOAPBodyElement[1];
            call.setSOAPActionURI("http://stockservice.contoso.com/wse/samples/2005/10/OCRWebServiceRecognize");
            String request="T H E     C O M P L E T E    R E Q U E S T    working in SOAP UI";
            InputStream requestStream = new ByteArrayInputStream(request.getBytes());
            requestElements[0] = new SOAPBodyElement(requestStream);
            call.setTimeout(200000);
            respElements = (Vector)call.invoke(requestElements);

            _buf.append(((SOAPBodyElement)respElements.get(0)).toString());
            _buf.append("\n");

            System.out.println(_buf.toString());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}