2011-02-03 2 views
1

숫자 값 매개 변수를 값을 받고 다시 돌려주는 웹 서비스에 전달하려고합니다.숫자 매개 변수를 Java 클라이언트에서 웹 서비스로 전달하는 데 문제가 있습니다.

@WebMethod(operationName = "getNumber") 
public Integer getNumber(@WebParam(name = "i") 
Integer i) { 
    //TODO write your implementation code here: 
    System.out.println("number : "+i); 
    return i; 
} 

이 내 클라이언트 코드의 조각입니다 :

Map results = FastMap.newInstance(); 
    results.put("result", "success"); 

    String endPoint = "http://localhost:8084/ProvideWS/MathWS"; 
    URL endpoint=null; 
    try{ 
     endpoint = new URL(endPoint); 
    } 
    catch (MalformedURLException e) { 
     org.ofbiz.base.util.Debug.log("Location not a valid URL "+e); 
     // TODO: handle exception 
    } 
    Service service = null; 
    Call call = null; 
    try{ 
     service = new Service(); 

     call = (Call)service.createCall(); 
     call.setTargetEndpointAddress(endpoint); 
     String nameSpace = "http://ws/"; 

     String serviceName = "getNumber"; 

     call.setOperationName(new QName(nameSpace, serviceName)); 

     call.addParameter("i",org.apache.axis.Constants.XSD_INTEGER , ParameterMode.IN); 
     call.setReturnType(org.apache.axis.Constants.XSD_INTEGER); 

     Object msg[] = new Object[]{new Integer(5)};  
     for (Object o : msg) { 
      org.ofbiz.base.util.Debug.log("object to be sent===== "+o.toString()); 
     } 
     Object ret = call.invoke(msg); 
     results.put("result", "result : "+ ret.toString()); 

    } 
    catch (Exception e) { 
     // TODO: handle exception 
     e.printStackTrace(); 
     org.ofbiz.base.util.Debug.log("exc when running soap client test : "+e); 
     results.put("result", "error : "+e); 
    } 
    return results; 

문제가 항상 0 (서버가받은 클라이언트의 반환 값이 이 웹 메소드의 조각이다 number as zero), 매개 변수를 전달할 때 사용한 메서드는 매개 변수가 String 일 때 올바르게 작동합니다. I.ve는 서버에서 반환 값을 하드 코딩하려고 했으므로 클라이언트의 출력이 좋으므로 서버가 매개 변수를 검색하는 방법이 문제라고 생각했습니다.

이것이 일어난 이유와 해결 방법에 대해 알고 계십니까?

어떤 도움

은 감사

답변

0

나는 당신의 문제 원인을 알 수없는, 이해할 수있을 것이다. 그러나 내가 할 첫 번째 일은 서버로 보내지는 실제 요청을 캡처하는 것입니다. 루트 문제가 클라이언트 측인지 서버 측인지 여부에 대한 단서를 제공해야합니다.

+0

답장을 보내 주셔서 감사합니다. 방금 문제를 해결했습니다. 클라이언트와 서버 간의 불일치 인코딩 때문에 [토론] (http://forums.oracle.com/forums/thread.jspa?threadID=333757&start=0&tstart= 0). 나는'call.setEncoding (null);'코드를 추가하여 그것을 해결했다. 문제를 일으켜서 미안 해요. – rin

관련 문제