2015-01-26 7 views
0

wsdl 파일에서 c 파일을 생성하기 위해 axis2c를 사용했습니다.wsdl2c에서 생성 된 c 파일을 사용하여 webservice에 연결하는 방법

adb_helloName.c 
adb_helloNameResponse.c 
axis2_extension_mapper.c 
axis2_stub_HelloService.c 
plus I have their header files. and a HelloServiceClient.vcproj file. 

내가 비주얼 스튜디오에서 프로젝트를 만들어 지금은 내가 웹 서비스에 연결하는 방법을 알고 반환 값을 얻으려면 : (this is the WSDL file I used) 는 지금은 이러한 파일 목록을 가지고있다. (이 경우 이름을 가져오고 "Hello + (thatName)"을 전달하는 hello world wsdl 파일이 있음)

감사합니다.

답변

1

해결책을 찾았습니다. 내 자신의 wsdl 파일로 내 서버를 만들려고했습니다.

나는 두 숫자 값을 가져옵니다 JAVA에 서버를 만들어 함께 추가 :
public class Math { 

    public int addOperator(int num1, int num2){ 
     return (num1+num2); 
    } 
} 

다음 이클립스에서에서 WSDL 파일을 만들었습니다. WSDL 파일에서 내가는 C 파일 생성 :

adb_addOperator.c을

adb_addOperatorResponse.c

axis2_extension_mapper.c

axis2_stub_MathService.c

플러스 나는 그들의 헤더가 파일.

MathServiceClient.vcproj 파일

이 프로젝트를 Visual Studio에서 가져 왔습니다. 는 그럼 난 내 프로젝트에이 math.c 파일을 추가 :

#include "axis2_stub_MathService.h" 

int main(
    int argc, 
    char *argv) 
{ 
    axutil_env_t * env = NULL; 
    axis2_char_t * operation = NULL; 
    axis2_char_t * client_home = NULL; 
    axis2_char_t * endpoint_uri = NULL; 
    axis2_stub_t * stub = NULL; 
    adb_addOperatorResponse_t * add_res = NULL; 
    adb_addOperator_t * add_in = NULL; 
    int res_val = 0; 
    endpoint_uri = "http://localhost:8080/AddOperator/services/Math"; //this is the tomcatServer running the MathServer 
    env = axutil_env_create_all("alltest.log", AXIS2_LOG_LEVEL_TRACE); 

    /* Set up deploy folder. */ 
    client_home = AXIS2_GETENV("AXIS2C_HOME"); 
    if (!client_home) 
     client_home = "../../../deploy"; 
    stub = axis2_stub_create_MathService(env, client_home, endpoint_uri); 
    add_in = adb_addOperator_create(env); 
    adb_addOperator_set_num1(add_in, env, 14); //initializing num1 
    adb_addOperator_set_num2(add_in, env, 33); //initializing num2 
    add_res = axis2_stub_op_MathService_addOperator(stub, env, add_in); 
    if (!add_res) 

    { 
     printf("Error: response NULL\n"); 
     return -1; 
    } 
    res_val = adb_addOperatorResponse_get_addOperatorReturn(add_res, env); 
    printf("Add Result : %d ", res_val);  

    return 0; 
} 

프로젝트를 컴파일. cmd를 연 다음 MathService.exe 디렉토리를 열었습니다. 그 다음에 MathService를 실행했습니다. 제대로 작동했습니다.