Passing date to ASMX web service

user2636982

I use asmx web service writes in c# over android device.

I make connection and when in some web method I need integer or string like input param,all work great, but problem is when web method need date, I try to send date in many format but always I have problem to get answer.

I need to send date object, or like string? It is possible that web service view date like something else?

This is method for "communication" with web service:

public void connectSOAP() 
{
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    String dateStr = "04/05/2010"; 
    Date dateObj=null;
    SimpleDateFormat curFormater = new SimpleDateFormat("dd/mmm/yyyy"); 
    try 
    {
        dateObj = curFormater.parse(dateStr);
    } 
    catch (java.text.ParseException e1) 
    {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } 
    request.addProperty("dtFrom",dateObj);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

    envelope.setOutputSoapObject(request);
    envelope.dotNet = true;
    try 
    {
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.call(SOAP_ACTION, envelope);
        if (envelope.getResponse() != null) 
        {
            if (envelope.bodyIn instanceof SoapFault) 
            {
                String str = ((SoapFault) envelope.bodyIn).faultstring;
                Log.i("", str);
            } 
            else 
            {
                SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
                Log.d("WS", String.valueOf(resultsRequestSOAP));
            }    
        };
    } 
    catch (Exception e) 
    {
        Log.d("WS","sss");
    }
}

When i change web method(something with out date it work),I get response in log) But when is this way with date i just get catch ("sss" ) in log,i debug and find that it brake on: androidHttpTransport.call(SOAP_ACTION, envelope);

But i not find anything about that in log except catch that i set...

Kr15

For me this looks like the dateObj which you want to give to the webservice can not be parsed, thats why the exception occurre at this line:

androidHttpTransport.call(SOAP_ACTION, envelope);

But as your formatter has this format:

SimpleDateFormat curFormater = new SimpleDateFormat("dd/mmm/yyyy"); 

Maybe the (three!)"mmm" are causing the error?? I am pretty sure this will produce something like e.g. "Feb" for February and so on.. (e.g. "11/Feb/2014"):

Try something like:

SimpleDateFormat curFormater = new SimpleDateFormat("dd/mm/yyyy"); 

or

SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yyyy"); 

Btw, to avoid localisation and interoperability issues, i often use DateTime objects accurately formatted to Strings for giving that objects over to WebService. Because many times i had problems by interoperability between e.g. .asmx Webservice and J2EE web service (e.g. the range of DateTime is not the same for J2EE and .NET and if it's a null/nil value you also run in troubles).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Run asmx web service on STA

From Dev

Async call of ASMX web service

From Dev

Consuming .asmx Web Service in java?

From Dev

Running a .asmx Web service as a Windows Service

From Dev

Getting the IP address of the client on an ASMX Web service

From Dev

jQuery ajax request from asmx web service

From Dev

Deserialization of ASMX web service failing partially

From Dev

Effects of adding new method to asmx web service

From Dev

Getting the IP address of the client on an ASMX Web service

From Dev

“Could not find a part of the path” asmx web service

From Dev

Deploy an asmx web service to a shared hosting server

From Dev

Call ASMX web service with parameter and get value from that web service?

From Dev

Invoking a web service - asmx - through a Microsoft Web API end point?

From Dev

ASMX web-service work on both HTTP and HTTPs

From Dev

can an ASMX web service response back with Response.BinaryWrite?

From Dev

How to get JSON response from a 3.5 asmx web service

From Dev

Create a asmx web service in C# using visual studio 2013

From Dev

How to manipulate Port Type in asmx Web Service (wsdl)?

From Dev

How to view my classes from asmx web service

From Dev

ASMX Web Service "Server did not recognize the value of HTTP Header SOAPAction"

From Dev

Publish asmx web service to FTP server given parser error

From Dev

Web Service(.asmx) is throwing 404 error in IIS 7

From Dev

Send file with ajax of jQuery to web service in C# (asmx)

From Dev

How to pass JSON parameter with $ajax to asmx web service

From Dev

what is the right way to spawn thread for database IO in asmx web service?

From Dev

How to use JQuery to return HTML page from ASMX web service

From Dev

Add a web service (ASMX) to existing asp.net forms website

From Dev

jqgrid toolbar filter parameters in link with .asmx web service

From Dev

Create a asmx web service in C# using visual studio 2013

Related Related

  1. 1

    Run asmx web service on STA

  2. 2

    Async call of ASMX web service

  3. 3

    Consuming .asmx Web Service in java?

  4. 4

    Running a .asmx Web service as a Windows Service

  5. 5

    Getting the IP address of the client on an ASMX Web service

  6. 6

    jQuery ajax request from asmx web service

  7. 7

    Deserialization of ASMX web service failing partially

  8. 8

    Effects of adding new method to asmx web service

  9. 9

    Getting the IP address of the client on an ASMX Web service

  10. 10

    “Could not find a part of the path” asmx web service

  11. 11

    Deploy an asmx web service to a shared hosting server

  12. 12

    Call ASMX web service with parameter and get value from that web service?

  13. 13

    Invoking a web service - asmx - through a Microsoft Web API end point?

  14. 14

    ASMX web-service work on both HTTP and HTTPs

  15. 15

    can an ASMX web service response back with Response.BinaryWrite?

  16. 16

    How to get JSON response from a 3.5 asmx web service

  17. 17

    Create a asmx web service in C# using visual studio 2013

  18. 18

    How to manipulate Port Type in asmx Web Service (wsdl)?

  19. 19

    How to view my classes from asmx web service

  20. 20

    ASMX Web Service "Server did not recognize the value of HTTP Header SOAPAction"

  21. 21

    Publish asmx web service to FTP server given parser error

  22. 22

    Web Service(.asmx) is throwing 404 error in IIS 7

  23. 23

    Send file with ajax of jQuery to web service in C# (asmx)

  24. 24

    How to pass JSON parameter with $ajax to asmx web service

  25. 25

    what is the right way to spawn thread for database IO in asmx web service?

  26. 26

    How to use JQuery to return HTML page from ASMX web service

  27. 27

    Add a web service (ASMX) to existing asp.net forms website

  28. 28

    jqgrid toolbar filter parameters in link with .asmx web service

  29. 29

    Create a asmx web service in C# using visual studio 2013

HotTag

Archive