Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm using two web services from the same host: Earth Orientation Center

I can get each one to work on a fresh kernel but I cannot get both of them to work during the same instance of the kernel. I think this is a context problem so I have tried loading each one into their own context.

The Code Instal the service:

Needs["WebServices`"]

InstallService["http://hpiers.obspm.fr/eop-pc/webservice/server_MATRICE_EOP.php?wsdl"]

Make a call:

year = 2005;
month = 12;
day = 31;
hour = 12;
minute = 34;
seconde = 34;
pm = 1;
ut = 1;
nut = 1;
tides = 1;

wservice = 
 MATRICEfromDate[
 LaDate["theyear" -> year, "themonth" -> month, "theday" -> day, 
 "thehour" -> hour, "theminute" -> minute, "thesecond" -> seconde, 
 "thepm" -> pm, "theut" -> ut, "thenut" -> nut, 
  "thetides" -> tides]]

This works and I get a matrix.

complexType$2200["a11" -> 0.318954, "a12" -> 0.94777, 
 "a13" -> 0.000580507, "a21" -> -0.94777, "a22" -> 0.318954, 
 "a23" -> 0.0000409354, "a31" -> -0.000146358, "a32" -> -0.000563244, 
 "a33" -> 1.]

But now if I install the other web service

InstallService["http://hpiers.obspm.fr/eop-pc/webservice/server_EOP2.php?wsdl"]

Then make a call:

year = 2005;
month = 12;
day = 31;

wservice = 
 C04fromDate[
  LaDate["theyear" -> year, "themonth" -> month, "theday" -> day]]

It also works!

complexType$3424["MJD" -> 53735, "x" -> 0.053717, "y" -> 0.384245, 
"UT1UTC" -> -0.661133, "LOD" -> -1.6*10^-6, "dX" -> 0.000228, 
"dY" -> -0.000287, "xerr" -> 0.00014, "yerr" -> 0.000141, 
"UT1UTCerr" -> 1.7*10^-6, "LODerr" -> 0.0000135, "dXerr" -> 0.000098,
 "dYerr" -> 0.000091]

So what is my problem? When I go back an run the first function MATRICEfromDate I get:

SerializeSchemaInstance::children: Invalid children: thehour->12.

I cannot get both of them to work consistently in one kernel session. I think is has to do with the context of the LaDate

Edits

I have tried adding AllowShortContext -> False as was suggested. However, this did not work but it help open the door to a better understanding of the problem. I have now explicitly added a context:

InstallService["http://hpiers.obspm.fr/eop-pc/webservice/
server_MATRICE_EOP.php?wsdl", "First`", AllowShortContext -> False]

InstallService["http://hpiers.obspm.fr/eop-pc/webservice/
server_EOP2.php?wsdl", "Second`", AllowShortContext -> False]

I then call the web service with the following functions (I use the same inputs as above)

wservice = 
 First`MATRICEfromDate[
  First`LaDate["theyear" -> year, "themonth" -> month, 
  "theday" -> day, "thehour" -> hour, "theminute" -> minute, 
  "thesecond" -> seconde, "thepm" -> pm, "theut" -> ut, 
  "thenut" -> nut, "thetides" -> tides]]

and...

wservice = 
 Second`C04fromDate[
  Second`LaDate["theyear" -> year, "themonth" -> month, 
   "theday" -> day]]

The problem revolves to the context of LaDate. Here is a look at the variables in the two contexts:

?Second`*

C04fromDate dYerr$2982	MJD$2946   themonth$2872	xerr$2967
complexType$2943	dY$2964 thedate$2939	theyear$2867 x$2949
    dXerr$2979   LODerr$2976 thedate$2939$2987	                 
    dX$2961  LOD$2958	theday$2877 UT1UTC$2955	y$2952

Notice there is no LaDate. Now look at the other context:

?First`*

a11$2737	a23$2752 LaDate  thehour$2545	thesecond$2555
a12$2740	a31$2755 MATRICEfromDate theminute$2550	thetides$2575
a13$2743	a32$2758 thedate$2730	themonth$2535 theut$2565
    a21$2746   a33$2761	thedate$2730$2766	thenut$2570
a22$2749	complexType$2734 theday$2540	thepm$2560  

Here you will find the LaDate.

Some how I need to get a LaDate into each context because they are different.

Another attempt

I have taken the two web servers and placed them in separate packages inside the Begin["`Private`"]; section and then wrote a wrapper function which I exposed via usage and still no luck. I think I'm just going to parse old FORTRAN data files from the USNO

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Please Try adding AllowShortContext -> False to both InstallService functions.

To both:

 InstallService["http://hpiers.obspm.fr/eop-pc/webservice/server_MATRICE_EOP.php?wsdl", AllowShortContext -> False]

and

InstallService["http://hpiers.obspm.fr/eop-pc/webservice/server_EOP2.php?wsdl", AllowShortContext -> False]

Try the following hard coded SOAP Template using URFetch to POST with SOAPAction and content-type header

BeginPackage["EarthOrientationMatrix`", {"XML`"}];
EarthOrientationMatrix;
Begin["`Private`"];
EarthOrientationMatrix[EOPYear_, EOPMonth_, EOPDay_, EOPHour_, EOPMinute_, EOPSeconds_, EOPPM_, EOPUT_, EOPNUT_, EOPTides_] := 
Module[{result, payload, response, xmlresponse, vals}, 
payload = "<?xml version=\"1.0\"?>
 <SOAP-ENV:Envelope \
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \
xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" \
xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">
       \t<SOAP-ENV:Body>
   \t\t<ns1:MATRICEfromDate \
xmlns:ns1=\"http://hpiers.obspm.fr/eop-pc/webservice/\">
   \t\t\t<thedate>
   \t\t\t\t<theyear>" <> ToString[EOPYear] <> "</theyear>
   \t\t\t\t<themonth>" <> ToString[EOPMonth] <> "</themonth>
   \t\t\t\t<theday>" <> ToString[EOPDay] <> "</theday>
   \t\t\t\t<thehour>" <> ToString[EOPHour] <> "</thehour>
   \t\t\t\t<theminute>" <> ToString[EOPMinute] <> "</theminute>
   \t\t\t\t<thesecond>" <> ToString[EOPSeconds] <> "</thesecond>
   \t\t\t\t<thepm>" <> ToString[EOPPM] <> "</thepm>
   \t\t\t\t<theut>" <> ToString[EOPUT] <> "</theut>
   \t\t\t\t<thenut>" <> ToString[EOPNUT] <> "</thenut>
   \t\t\t\t<thetides>" <> ToString[EOPTides] <> "</thetides>
   \t\t\t</thedate>
   \t\t</ns1:MATRICEfromDate>
   \t</SOAP-ENV:Body>
   </SOAP-ENV:Envelope>";
   response = 
URLFetch[
     "http://hpiers.obspm.fr/eop-pc/webservice/server_MATRICE_EOP.\
php", "Method" -> "POST", 
 "Headers" -> {"SOAPAction" -> "MATRICEfromDate", 
   "Content-Type" -> "text/xml; charset=ISO-8859-1"}, 
 "BodyData" -> payload];
   xmlresponse = ImportString[response, "XML"];
   result = 
     Cases[Cases[xmlresponse, 
  XMLElement[{"http://hpiers.obspm.fr/eop-pc/webservice/", 
    "MATRICEfromDateResponse"}, {{"http://www.w3.org/2000/xmlns/",
       "ns1"} -> "http://hpiers.obspm.fr/eop-pc/webservice/"}, _],
   Infinity], 
 XMLElement[_, {{"http://www.w3.org/2001/XMLSchema-instance", 
      "type"} -> "xsd:decimal"}, {vals_}] -> vals, Infinity];
  Return[result]];
End[];
EndPackage[];


EarthOrientationMatrix[2005, 12, 31, 12, 34, 34, 1, 1, 1, 1]

{"0.318954397043", "0.947769885372", "0.000580507307", \ "-0.947770051851", "0.318954427996", "0.000040935409", \ "-0.000146358028", "-0.000563243969", "0.999999830668"}

And then the other method

BeginPackage["EarthOrientationParameters`", {"XML`"}];
EarthOrientationParameters;
Begin["`Private`"];

EarthOrientationParameters[EOPYear_, EOPMonth_, EOPDay_] := 
  Module[{result, payload, response, xmlresponse, vals}, 
   payload = "<?xml version=\"1.0\"?>
     <SOAP-ENV:Envelope \
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \
xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" \
xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">
 \t<SOAP-ENV:Body>
 \t\t<ns1:C04fromDate \
 xmlns:ns1=\"http://hpiers.obspm.fr/webservice/\">
     \t\t\t<thedate>
 \t\t\t\t<theyear>" <> ToString[EOPYear] <> "</theyear>
 \t\t\t\t<themonth>" <> ToString[EOPMonth] <> "</themonth>
 \t\t\t\t<theday>" <> ToString[EOPDay] <> "</theday>
 \t\t\t</thedate>
 \t\t</ns1:C04fromDate>
 \t</SOAP-ENV:Body>
 </SOAP-ENV:Envelope>";
    response = 
    URLFetch[
 "http://hpiers.obspm.fr/eop-pc/webservice/server_EOP2.php", 
 "Method" -> "POST", 
 "Headers" -> {"SOAPAction" -> "C04fromDate", 
   "Content-Type" -> "text/xml; charset=ISO-8859-1"}, 
 "BodyData" -> payload];
   xmlresponse = ImportString[response, "XML"];
    result = 
Cases[Cases[xmlresponse, 
  XMLElement[{"http://hpiers.obspm.fr/webservice/", 
    "C04fromDateResponse"}, {{"http://www.w3.org/2000/xmlns/", 
      "ns1"} -> "http://hpiers.obspm.fr/webservice/"}, _], 
  Infinity], XMLElement[_, _, {vals_}] -> vals, Infinity];
   Return[result]];
End[];
EndPackage[];

    EarthOrientationParameters[2005, 12, 31]

Since these methods do not use the WebService context or package you can call them repeatedly. I did not have time to clean up bloat or add in error trapping.

The LaDate Complex type is being overridden by the last Proxy class that is installed in the WebService. This lead me to believe that the order of the WebServices InstallService function may make a difference.

BeginPackage["EarthOrientationCenter`", {"WebServices`"}];
 EarthOrientationParameters;
 EarthOrientationMatrix;
 Begin["`Private`"];

 InstallService["http://hpiers.obspm.fr/eop-pc/webservice/server_EOP2.php?wsdl"]
 InstallService["http://hpiers.obspm.fr/eop-pc/webservice/server_MATRICE_EOP.php?wsdl"];

 EarthOrientationParameters[EOPYear_, EOPMonth_, EOPDay_] := 
   Module[{result}, 
    result = 
     C04fromDate[
 LaDate["theyear" -> EOPYear, "themonth" -> EOPMonth, 
  "theday" -> EOPDay,
  "thehour" -> 1, "theminute" -> 1, "thesecond" -> 1, 
  "thepm" -> 1, "theut" -> 1, "thenut" -> 1, "thetides" -> 1]];
   Return[result]];

 EarthOrientationMatrix[EOPYear_, EOPMonth_, EOPDay_, EOPHour_, 
   EOPMinute_, EOPSeconds_, EOPPM_, EOPUT_, EOPNUT_, EOPTides_] := 
   Module[{result}, 
    result = 
     MATRICEfromDate[
      LaDate["theyear" -> EOPYear, "themonth" -> EOPMonth, 
  "theday" -> EOPDay, "thehour" -> EOPHour, 
  "theminute" -> EOPMinute, "thesecond" -> EOPSeconds, 
  "thepm" -> EOPPM, "theut" -> EOPUT, "thenut" -> EOPNUT, 
  "thetides" -> EOPTides]];
    Return[result]];
End[];
EndPackage[];

Executing

   EarthOrientationParameters[2005, 12, 13]
 (* EOP`EOPPort`complexType$1935["MJD" -> 53717, "x" -> 0.063063, 
 "y" -> 0.388017, "UT1UTC" -> -0.653458, "LOD" -> 0.0004528, 
 "dX" -> 0.000251, "dY" -> -0.000145, "xerr" -> 0.000117, 
 "yerr" -> 0.00012, "UT1UTCerr" -> 3.*10^-6, "LODerr" -> 0.000014, 
 "dXerr" -> 0.000082, "dYerr" -> 0.000076] *)

and

    EarthOrientationMatrix[2005, 12, 13, 12, 34, 34, 1, 1, 1, 1]
 (* EOP`EOPPort`complexType$2212["a11" -> 0.0149869, "a12" -> 0.999888, 
 "a13" -> 0.000573122, "a21" -> -0.999888, "a22" -> 0.0149868, 
 "a23" -> 0.0000406349, "a31" -> 0.0000320411, "a32" -> -0.000573667, 
 "a33" -> 1.] *)

I repeated the calls multiple times with no errors. This was done without having to deal with SOAP or WSDL files. I also found a solution by modifying the LaDate ComplexType in the C04 method and calling it UneDate instead of LaDate and hosting the WSDL file on a local webserver (anything that can serve a file using HTTP). This solution on requires the user set the extra variables to an integer. ComplexType in the same context are non-commutative? Order matters?

share|improve this answer
    
Thank you but still no luck? If you are also testing make sure that you call each function at least twice because there is an order in which both work. This was also the order I ran the first time giving me false hope –  c186282 Sep 12 '13 at 20:06
    
@c186282 This was the order I ran it as in your first post. The error did not appear. I took a quick look at the WSDL files. Even if the InstallService does not yield a solution. One can always write full SOAP wrapper template to be submitted to the webservice. If the webservice will take HTTP POST parameters then alternative solutions exist. –  Hans Sep 12 '13 at 20:50
    
Writing WSDL or a full SOAP wrapper falls outside of my skill set (and attention span). I was hoping to use these services as a quick test to other work I'm doing. Thanks for your help –  c186282 Sep 12 '13 at 21:32
    
@Hans: I can confirm this to not work with several versions on windows. As I understand you didn't see the error, which version/OS do you use? –  Albert Retey Sep 13 '13 at 10:51
1  
@AlbertRetey I believe I found another workaround by calling the CO4FronDate method with extra defaulted parameters. The resulting SOAP message sent never uses those extra parameters. –  Hans Sep 17 '13 at 20:35
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.