Exercise Thing problem

Oct 11, 2011 at 6:03 AM

Hi,

I am trying to Sync Exercise data with HealthVault. I got the following exception

<!--?xml version="1.0" encoding="utf-8"?-->3Invalid xml for thing. The 'urn:com.microsoft.wc.thing.aerobic:exercise' element is not declared. -- The 'urn:com.microsoft.wc.thing.aerobic:exercise' element is not declared.failed-item-index=0

Here is my test code:

package com.microsoft.hsg.jaxb;

import junit.framework.Assert;

import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.microsoft.hsg.ConnectionFactory;
import com.microsoft.hsg.methods.jaxb.SimpleRequestTemplate;
import com.microsoft.hsg.methods.jaxb.putthings.request.PutThingsRequest;
import com.microsoft.hsg.methods.jaxb.putthings.response.PutThingsResponse;
import com.microsoft.hsg.thing.oxm.jaxb.base.CodableValue;
import com.microsoft.hsg.thing.oxm.jaxb.dates.ApproxDate;
import com.microsoft.hsg.thing.oxm.jaxb.dates.ApproxDateTime;
import com.microsoft.hsg.thing.oxm.jaxb.dates.StructuredApproxDate;
import com.microsoft.hsg.thing.oxm.jaxb.exercise.Exercise;
import com.microsoft.hsg.thing.oxm.jaxb.thing.Thing;

@RunWith(JMock.class)
public class PutThingsTest {
	

	private Mockery context = new JUnit4Mockery() {{
        setImposteriser(ClassImposteriser.INSTANCE);
    }};

	/**
     * Create the test case
     *
     */
    public PutThingsTest()
    {
    }
    
    @Test
    public void PutThing() throws Exception
    {
    	SimpleRequestTemplate requestTemplate = new SimpleRequestTemplate(
    			ConnectionFactory.getConnection());
    	requestTemplate.setPersonId("b84ea658-d48b-4c8a-acc6-f903c0394ed6");
    	requestTemplate.setRecordId("0ddd8062-26e6-4acb-858a-ee77d678b759");
    	
    	Exercise exercise = new Exercise();
    	
    	CodableValue value = new CodableValue();
    	value.setText("hike");
    	exercise.setActivity(value);
    	
    	ApproxDate approxDate = new ApproxDate();
    	approxDate.setD(new Integer(27));
    	approxDate.setM(new Integer(9));
    	approxDate.setY(2011);
    	
    	ApproxDateTime dateTime = new ApproxDateTime();
    	StructuredApproxDate structuredApproxDate = new StructuredApproxDate();
    	
    	structuredApproxDate.setDate(approxDate);
    	dateTime.setStructured(structuredApproxDate);
    	exercise.setWhen(dateTime);
    	exercise.setDuration(new Double(30));
    	
    	Thing thing = new Thing();
    	thing.setData(exercise);
    	
    	PutThingsRequest request = new PutThingsRequest();
    	request.getThing().add(thing);
    	
    	PutThingsResponse response = (PutThingsResponse)requestTemplate.makeRequest(request);
    	
    	Assert.assertNotNull(response);
    }
}

Am I doing anything wrong here?

Thanks for your help in advance.

Oct 14, 2011 at 12:52 AM

Hi,

Please help me in regarding to this issue.

Thanks,

Coordinator
Oct 19, 2011 at 11:50 PM

Hi bachi,

The type-id the library was using was incorrect for the Exercise type.  I checked in the correct type-id.  If you checkout and build the trunk, it should work for you.

 

--Rob