Web service in live environment

0
Hi All, In my mendix web application i have created a "Published webservice" which i can access locally. using this URL http://localhost:8080/ws-doc/. after deploying the application to the cloud server i tried accessing the web service by using the following URL https://myapplication.com/ws-doc which doesn't work. Is there something i am doing wrong?. The idea is to consume the mendix web service from a C# application. Help will be much appriciated
asked
6 answers
0

the url ws-doc points to the web service documentation, the actual handler is called ws but you can also see this in your WSDL.

answered
0

And remember that the wsdl and xsd is not reachable from the cloud. You should provide the wsdl and xsd (copied from your local environment) and give that to the other party that wants to consume your webservice.

Ronald

answered
0

Hi All, Thanks for your response, @Bas when i changed the URL to "https://myapplication.com/ws/" as instructed i get the following error "<faultcode>Client</faultcode> <faultstring>Service name should be specified</faultstring>". @ Ronald thanks i will try that

answered
0

In your example you are using /ws-doc/ locally and /ws-doc on the cloud server. Only /ws-doc/ (note the second slash) is correct.

answered
0

One thing is that your URL is wrong and may be some times you also need a port. It should be: https://myapplication.com/ws/ or https://myapplication.com:8080/ws/

Make sure you create a proper security serilization envelope for the header. This is how i did it in java using ksoap on Android.

/**
 * This is used to create the security header for the SOAP service
 * 
 * @param email
 *            is a {@link String} for the username used in Authentication
 * @param Password
 *            is {@link String} for the Password used in Authentication
 * @return a {@link SoapSerializationEnvelope} used as {@link SoapEnvelope}
 * 
 */
public static SoapSerializationEnvelope CreateSoapEnvelope(String Email,
        String Password) {

    SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    soapEnvelope.implicitTypes = true;
    soapEnvelope.dotNet = false;


    Element authHeader = new Element();
    authHeader.setNamespace("http://schemas.xmlsoap.org/ws/2002/04/secext");
    authHeader.setName("Security");

    Element subAuthHeader = new Element();
    subAuthHeader
            .setNamespace("http://schemas.xmlsoap.org/ws/2002/04/secext");
    subAuthHeader.setName("UsernameToken");

    Element username = subAuthHeader.createElement(
            "http://schemas.xmlsoap.org/ws/2002/04/secext", "Username");
    username.addChild(Node.TEXT, Email);
    subAuthHeader.addChild(Node.ELEMENT, username);

    Element password = subAuthHeader.createElement(
            "http://schemas.xmlsoap.org/ws/2002/04/secext", "Password");
    password.addChild(Node.TEXT, Password);
    subAuthHeader.addChild(Node.ELEMENT, password);

    authHeader.addChild(Node.ELEMENT, subAuthHeader);

    soapEnvelope.headerOut = new Element[] { authHeader };

    return soapEnvelope;
}

And make sure that you have set the right action on your calls. example below creates a proper serialization header and gets all the projects from the webservice.

public VectorWSProject GetAllProjects(List<HeaderProperty> headers){
    SoapObject soapReq = new SoapObject(NAMESPACE, ACTION);

    SoapSerializationEnvelope soapEnvelope = CommonFunctions
            .CreateSoapEnvelope(EMAIL, PASSWORD);       

    soapEnvelope.setOutputSoapObject(soapReq);
    HttpTransportSE httpTransport = new HttpTransportSE(url, timeOut);

    VectorWSProject resultVariable = new VectorWSProject();
    try{
        if (headers != null) {
            httpTransport.call("http://192.168.1.128:8080/" + ACTION,
                    soapEnvelope, headers);
        } else {
            httpTransport.call("http://192.168.1.128:8080/" + ACTION,
                    soapEnvelope);
        }
        SoapObject result=(SoapObject)soapEnvelope.bodyIn;           

        if (result.getName().equals("GetAllProjectsResponse"))
        {
            resultVariable = new VectorWSProject(result);

        }
    }catch (Exception e) {
        if (eventHandler != null)
            eventHandler.Wsdl2CodeFinishedWithException(e);
        e.printStackTrace();
    }
    return resultVariable;
}

In case you are still having issues consider using SOAP UI to help you out. You can also consult Flock of Birds to help you out :)

answered
0

Hi All,

Thanx for your input, @Jaap my URL i have tried that however its incorrect. The correct URL is https://myapplication.com/ws/. @Acellam, thanx for sharing your code with me, I will be trying your solution soon. I am just trying to figure out why i am receiving the following error

<faultcode>Client</faultcode> <faultstring>Service name should be specified</faultstring>

I get the exact same error when i use the application locally and obviously changing the URL to local host as follows.

http://localhost:8080/ws/ - This way i receive the above error
http://localhost:8080/ws-doc/ - Using this approach i receive a responses from the web service.

To my understanding the logic would be more or less the same after deploying to the web service so my URL will look as follows

https://myapplication.com/ws/My_Webservice/ - I receive a response, with an error stating the below

<faultcode>Server</faultcode> <faultstring> com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog at [row,col {unknown-source}]: [1,0] </faultstring>

https://myapplication.com/ws-doc/ - gives me the error "404 Not Found nginx"

answered