Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java consuming a iseries webservice - cant't figure out how to pass a string to a object class type

31 views
Skip to first unread message

joao dinis

unread,
Jan 6, 2021, 11:40:02 AM1/6/21
to
I am an old rpg programmer and not very skilled with java, self learning but this one caught me and I need help solving this.

I have a webservice running on iseries that receives a string variable, my problem is pass this variable to the method that invokes the service, because it is not string or int or something like that, is a class type and here is the point.

My java is like this:

package jdws3;
import iseries.wsbeans.wsstk01a.xsd.WSSTK01AInput;
import iseries.wsbeans.wsstk01a.xsd.WSSTK01AResult;
import java.util.Scanner;
public class JdWS3 {
public static void main(String[] args) {
Scanner obj = new (System.in);
System.out.println("Article Code: ");
String codart = obj.next();

WSSTK01AInput param0 = new WSSTK01AInput();

******** I tried in so many ways and don't figure how i can pass the variable 'codart' to param0 (type WSSTK01AInput) ********


System.out.println("Article name= "+wsstk01AXML(param0));
// this works and prints 'wrong article': <?xml version="1.0" encoding="UTF-8"?>
<WSSTK01A>
<NOMEARTIGO></NOMEARTIGO>
<ERRMSG>Artigo errado.</ERRMSG>
</WSSTK01A>

}


private static String wsstk01AXML(iseries.wsbeans.wsstk01a.xsd.WSSTK01AInput param0) {
iseries.wsbeans.wsstk01a.WSSTK01A service = new iseries.wsbeans.wsstk01a.WSSTK01A();
iseries.wsbeans.wsstk01a.WSSTK01APortType port = service.getWSSTK01ASOAP11PortHttp();
return port.wsstk01AXML(param0);
}

} // end of jdws3.java


WSSTK01AInput:


package iseries.wsbeans.wsstk01a.xsd;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlType;


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

@XmlElementRef(name = "_CODART", namespace = "http://wsstk01a.wsbeans.iseries/xsd", type = JAXBElement.class, required = false)
protected JAXBElement<String> codart;

/**
* Gets the value of the codart property.
*
* @return
* possible object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public JAXBElement<String> getCODART() {
return codart;
}

/**
* Sets the value of the codart property.
*
* @param value
* allowed object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public void setCODART(JAXBElement<String> value) {
this.codart = value;
}

}

0 new messages