【问题标题】:JAVA Web Service with SOAP Client Objective C---Response problemJAVA Web Service with SOAP Client Objective C---响应问题
【发布时间】:2011-11-06 21:48:11
【问题描述】:

我有这个 Java 网络服务:

@WebService(serviceName = "Catalogo_V1")
public class Catalogo_V1 {

    /** This is a sample web service operation */
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) 
    {
        return "Hello " + txt + " !";
    }
}

Objective C 中的这一部分(使用 WSDL2ObjC 生成代码后):

- (IBAction)buttonPressed:(id)sender 
{

    Catalogo_V1PortBinding *binding = [[Catalogo_V1Svc Catalogo_V1PortBinding] initWithAddress:@"http://localhost:8080/WSServer/Catalogo_V1.wsdl"];
    binding.logXMLInOut = YES;  // to get logging to the console.

    Catalogo_V1Svc_hello *r = [[Catalogo_V1Svc_hello alloc] init];

    //NSLog(@"request: %@",r);

    [r setName:i.text];
    //NSLog(@"string: %@ ",i.text);

    Catalogo_V1PortBindingResponse *resp = [binding helloUsingParameters:(Catalogo_V1Svc_hello *)r];

    NSLog(@"response: %@",resp);

    for (id mine in resp.bodyParts)
    {
        if ([mine isKindOfClass:[Catalogo_V1Svc_helloResponse class]])
        {
            //lab.text = [mine Catalogo_V1Svc_helloResponse];
        }
    }
}

我的控制台显示以下消息:

2

011-08-30 17:00:11.572 Catalogo-V1[3876:207] OutputHeaders:
{
    "Content-Length" = 451;
    "Content-Type" = "text/xml; charset=utf-8";
    Host = localhost;
    Soapaction = "";
    "User-Agent" = wsdl2objc;
}
2011-08-30 17:00:11.572 Catalogo-V1[3876:207] OutputBody:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:Catalogo_V1Svc="http://org/" xsl:version="1.0">
  <soap:Body>
    <Catalogo_V1Svc:hello>
      <Catalogo_V1Svc:name>ddddddd</Catalogo_V1Svc:name>
    </Catalogo_V1Svc:hello>
  </soap:Body>
</soap:Envelope>
2011-08-30 17:00:11.593 Catalogo-V1[3876:207] Response HTTP:
<NSHTTPURLResponse: 0x5b1ffd0>
2011-08-30 17:00:11.593 Catalogo-V1[3876:207] ResponseStatus: 404
2011-08-30 17:00:11.593 Catalogo-V1[3876:207] ResponseHeaders:
{
    "Content-Length" = 1067;
    "Content-Type" = "text/html";
    Date = "Tue, 30 Aug 2011 15:00:11 GMT";
    Server = "GlassFish Server Open Source Edition 3.1.1";
    "X-Powered-By" = "Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.1 Java/Apple Inc./1.6)";
}
2011-08-30 17:00:11.617 Catalogo-V1[3876:207] ResponseError:
Error Domain=Catalogo_V1PortBindingResponseHTTP Code=404 "not found" UserInfo=0x5b2a320 {NSLocalizedDescription=not found}
2011-08-30 17:00:11.618 Catalogo-V1[3876:207] response: <Catalogo_V1PortBindingResponse: 0x5b25bd0>

输出正确,但我没有收到任何响应....

【问题讨论】:

  • 错误 404 表示您的客户端没有正确响应。
  • 好的,问题出在客户端,但是在哪里????

标签: java objective-c http soap http-status-code-404


【解决方案1】:

您的服务器以HTTP status 404 (File Not Found) 响应,这意味着客户端将其 SOAP 请求发布到服务器未配置为响应的端点 (URL)。

例如,您的客户可能会被定向到http://localhost:8080/foo 但服务器正在http://localhost/bar 监听。

检查客户端上的端点 URL 和服务器配置,以确保它正在侦听相同的 URL。

【讨论】:

  • 感谢 Maerics! -->> 这是正确的形式“localhost:8080/WSServer/Catalogo_V1”,但我在最后一个“if”中有其他小问题,我不知道如何提取我的参数...
  • 有很多事情会导致错误 404:端口号无效/丢失、URL 错误/不完整、命名空间无效、意外/无效字符等。唯一常见的根本原因是“客户搞砸了”:)
  • 现在我没有任何错误,但是我的服务器在没有发送参数的情况下返回响应.....非常感谢!!当不知道某事如此困难时,解决任何问题......
猜你喜欢
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多