2011-08-30 79 views
1

我在Java中,这Web服务:JAVA的Web Service与SOAP客户端目标C ---响应问题

@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]; 
     } 
    } 
} 

和我的控制台显示此消息:

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> 

输出其正确的,但我不收到任何回应....

+0

错误404意味着您的客户端没有正确响应。 – paulsm4

+0

好的,问题出在客户端,但是哪里? – Davidin073

回答

1

你的服务器HTTP status 404 (File Not Found)响应,这意味着客户端发布的SOAP请求的端点(URL),该服务器没有被配置为回应。

例如,您的客户端可能指向http://localhost:8080/foo ,但服务器正在监听http://localhost/bar

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

+0

谢谢Maerics !!! - >>这是正确的形式“http:// localhost:8080/WSServer/Catalogo_V1”但我有最后一个“如果”其他小问题,我不知道如何提取我的参数... – Davidin073

+0

有很多可能导致错误的事情404:无效/丢失端口#,错误/不完整的URL,无效的命名空间,意外/无效字符等等等等。唯一的共同根本原因是“客户端搞砸了”:) – paulsm4

+0

现在我没有错误,但我的服务器返回响应没有我的参数发送.....很多谢谢!当不知道什么是如此困难解决任何问题... – Davidin073