java - 如果soapAction 是URN :something?,我的URL 是什么

标签 java android web-services soap wsdl

The image shows the WSDL for web serice i have created and i am getting the soapAction as "URN:authentication" authentication is my method name.

上图显示了我创建的 Web 服务的 WSDL,并且我得到了soapAction,因为“URN:authentication”身份验证是我的方法名称

我想知道soapAction的url,因为我在使用android连接到web服务时遇到空点异常。 我已经使用 AXIS 2 创建了 Web 服务。

公共(public)类MainActivity扩展了Activity { EditText用户名、密码;

private final String NAMESPACE = "http://nepal.blue_book.com";
private final String URL = "http://192.168.1.104:8088/Blue_Book/services/Login_service?wsdl";
private final String SOAP_ACTION = "urn:authentication";
private final String METHOD_NAME = "authentication";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button login = (Button) findViewById(R.id.btnLogin);
    login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            loginAction();

        }
    });
}

public void loginAction() {
    username = (EditText) findViewById(R.id.textusername);
    Password = (EditText) findViewById(R.id.textpassword);




    if (username.getText().toString().equals("")) {
        Toast.makeText(getApplicationContext(), "Please Enter User Name",
                Toast.LENGTH_SHORT).show();
    }

    else if (Password.getText().toString().equals("")) {
        Toast.makeText(getApplicationContext(), "Please Enter Password",
                Toast.LENGTH_SHORT).show();
    }

    else
    {
        Toast.makeText(getApplicationContext(), "login",
                Toast.LENGTH_SHORT).show();

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        EditText userName = (EditText) findViewById(R.id.textusername);
        String user_Name = userName.getText().toString();
        EditText userPassword = (EditText) findViewById(R.id.textpassword);
        String user_Password = userPassword.getText().toString();

        Log.i("user name ", user_Name);
        Log.i("user password ", user_Password);

      //Pass value for userName variable of the web service
        PropertyInfo unameProp =new PropertyInfo();
        unameProp.setName("userName");//Define the variable name in the web service method
        unameProp.setValue(user_Name);//set value for userName variable
        unameProp.setType(String.class);//Define the type of the variable
        request.addProperty(unameProp);//Pass properties to the variable

      //Pass value for Password variable of the web service
        PropertyInfo passwordProp =new PropertyInfo();
        passwordProp.setName("password");
        passwordProp.setValue(user_Password);
        passwordProp.setType(String.class);
        request.addProperty(passwordProp);

        Log.i("request ....", request.toString());

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        Log.i("test .........", "hello 0");

        try{
            androidHttpTransport.call(SOAP_ACTION, envelope);
            Log.i("test test.........", "hello 1");
               SoapPrimitive response = (SoapPrimitive)envelope.getResponse();



               Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_SHORT).show();

               Log.d("result ........", response.toString());
              /* TextView result = (TextView) findViewById(R.id.tv_status);
               result.setText(response.toString());*/

        }
        catch(Exception e)
        {
            Log.e("erros ......", e.getMessage().toString());


        }
       }

    }

上图是连接soap服务的android代码。我总是得到一个空点异常,因为控制将捕获部分。 log cat error

上图是logcat错误

最佳答案

private final String URL = "http://192.168.1.104:8088/Blue_Book/services/Login_service?wsdl";
private final String NAMESPACE = "http://nepal.blue_book.com";

试试这个,

 private final String URL = "http://192.168.1.104:8088/Blue_Book/services/Login_service";
private final String NAMESPACE = "http://nepal.blue_book.com/";

关于java - 如果soapAction 是URN :something?,我的URL 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21652017/

相关文章:

java - 将 nonfree 包含到 opencv4android

android - JSON 解析器性能低下

java - 为给定场景投票选出最佳协议(protocol)

java - 如何将 Spring Ws 中的 Soap 请求消息发送到接受 Soap 请求消息的服务器?

java - 如何将整列日期(以毫秒为单位)转换为java中的某种标准格式?

java - 获取消息的当前可见性超时

java - 构造函数 TFSTeamProjectCollection(String) 未定义

android - 如何强制渲染脚本版本修复 lint 错误 : GradleCompatible

java - 如何将现有的 SOAP 请求消息导入 SoapUI?

java - 使 JavaFX 应用程序线程等待另一个线程完成