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

1

I'm trying to consume a SOAP web service using the NetBeans IDE (JAVA), but when I try to compile a list it returns null.

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

Do I have to pass this information through another method?

Below is the data for the analysis;

Sharepoint SOAP Web Service;

link

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)
    
asked by anonymous 29.10.2018 / 04:04

0 answers