You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Mansour Al Akeel <ma...@gmail.com> on 2011/03/07 04:00:32 UTC

using jaxbri binding

I generated the stub to call a web service deployed internally. The response
is always null with this service.
Here's my test case:

@Test
public void testGetProduct()  {
        MapMap map = new MapMap();
        map.getMapEntry().add(createEntry("userLogin", "ofbiz"));
        map.getMapEntry().add(createEntry("idToFind", "PIZZA"));
        map.getMapEntry().add(createEntry("login.username", "admin"));
        map.getMapEntry().add(createEntry("login.password", "ofbiz"));
        FindProductById productData = new FindProductById();
        productData.setMapMap(map);
        FindProductByIdStub byId;
        try {
            byId = new FindProductByIdStub();
            FindProductByIdResponse response;
            response = byId.findProductById(productData);
            assertNotNull(response);
            MapMap m1 = response.getMapMap();
            assertNotNull(m1);
        } catch (AxisFault e1) {
            e1.printStackTrace();
        } catch (RemoteException e1) {
            e1.printStackTrace();
        }
    }

The wsdl is obtained from:

 wsdl2java.sh -uri "
http://localhost:8080/webtools/control/SOAPService/findProductById?wsdl" -d
jaxbri -o generated-code

Which is a web service from apache ofbiz. The null value for the object is
being returned from this generated code:

java.lang.Object object = fromOM(

_returnEnv.getBody().getFirstElement() ,

org.apache.ofbiz.service.FindProductByIdResponse.class,

getEnvelopeNamespaces(_returnEnv));


And this is the generate class FindProductById.java:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "mapMap"
})
@XmlRootElement(name = "findProductById")
public class FindProductById {

    @XmlElement(name = "map-Map", namespace = "", required = true)
    protected MapMap mapMap;

    /**
     * Gets the value of the mapMap property.
     *
     * @return
     *     possible object is
     *     {@link MapMap }
     *
     */
    public MapMap getMapMap() {
        return mapMap;
    }

    /**
     * Sets the value of the mapMap property.
     *
     * @param value
     *     allowed object is
     *     {@link MapMap }
     *
     */
    public void setMapMap(MapMap value) {
        this.mapMap = value;
    }

}

Thank you in advance.

Re: using jaxbri binding

Posted by Mansour Al Akeel <ma...@gmail.com>.
Ok, may be I need to include more details, and include the soap.
The binding is done with jaxb. The command to generate the stubs is:

wsdl2java.sh -uri
"http://akkatech.com/webtools/control/SOAPService/findProductById?wsdl"
-d jaxbri -o generated

When I access it, while debugging in eclipse, I can see the response
obtained correctely. However, after unmarshalling I get null results. Is
this a bug, or I am missing something.

    @Test
    public void testGetProduct() throws RemoteException {
            MapMap map = new MapMap();
            map.getMapEntry().add(createEntry("userLogin", "ofbiz"));
            map.getMapEntry().add(createEntry("idToFind", "PIZZA"));
            map.getMapEntry().add(createEntry("login.username", "admin"));
            map.getMapEntry().add(createEntry("login.password", "ofbiz"));
            FindProductById service = new FindProductById();
            service.setMapMap(map);
            FindProductByIdStub byId;
            byId = new FindProductByIdStub();
            FindProductByIdResponse response;
            response = byId.findProductById(service);
            assertNotNull(response);
            MapMap m1 = response.getMapMap();
            assertNotNull(m1);
    }

    private MapEntry createEntry(String key, String value) {

            StdString strKey = new StdString();
            strKey.setValue(key);
            MapKey mapKey = new MapKey();
            mapKey.setStdString(strKey);

            StdString strValue = new StdString();
            strValue.setValue(value);
            MapValue mapValue = new MapValue();
            mapValue.setStdString(strValue);

            MapEntry entry = new MapEntry();
            entry.setMapKey(mapKey);
            entry.setMapValue(mapValue);

            return entry;
    }

I am really stuck on this.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org