How to consume a java SOAP Web Service that requires User and Password?

Asked

Viewed 1,535 times

1

I am trying to consume a SOAP web service using Netbeans IDE (JAVA), but when I try to delete a list it returns null to me.

Talking to a colleague, he told me that it is for lack the user and network password of the company I work, however I am having difficulties to understand this process, since how can I pass this information to the web service that I am consuming.

I have to pass this information in another way?

Below goes with data for analysis;

SOAP Web Service made in Sharepoint;

http://minha.casa.com.br/Servicos/ServicosGerais/_vti_bin/Lists.asmx? wsdl

Class where the lists are.

package vamoLA;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="listName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "listName"
})
@XmlRootElement(name = "GetList")
public class GetList {

    protected String listName;

    /**
     * Gets the value of the listName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getListName() {
        return listName;
    }

    /**
     * Sets the value of the listName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setListName(String value) {
        this.listName = value;
    }

}

Class to call List.

package Wss;

import java.util.ArrayList;
import java.util.List;
import vamoLA.GetListResponse.GetListResult;

public class Testando {

    private String username;

    private String password;

    public static void main(String[] args) {
        
        GetListResult list = getList("T_CARDAPIO_PRATO");
        List<Object> content;
        content = new ArrayList<Object>();
        content = list.getContent();
        System.out.println("Resultado 1 " + content.get(0));

    }

    private static GetListResult getList(java.lang.String listName) {
        vamoLA.Lists service = new vamoLA.Lists();
        vamoLA.ListsSoap port = service.getListsSoap();
        return port.getList(listName);
    }
    
    
    

}

Callback.

ant -f C:\\Users\\casa\\Documents\\NetBeansProjects\\WSHell -Djavac.includes=Wss/Testando.java -Dnb.internal.action.name=run.single -Drun.class=Wss.Testando run-single
init:
Deleting: C:\Users\casa\Documents\NetBeansProjects\WSHell\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\casa\Documents\NetBeansProjects\WSHell\build\built-jar.properties
wsimport-init:
wsimport-client-Lists:
files are up to date
wsimport-client-generate:
Compiling 1 source file to C:\Users\casa\Documents\NetBeansProjects\WSHell\build\classes
compile-single:
run-single:

Resultado 1 [List: null]
BUILD SUCCESSFUL (total time: 2 seconds)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.