Search code examples
siplynclync-2013

Why do I get an MSPL exception "ProxyRequest only valid for sipRequest"


I'm writing a Lync MSPL application using a manifest and a windows service. In my manifest.am I have the following code:

<?xml version="1.0"?>
<r:applicationManifest
 r:appUri="http://www.company.no/LyncServerFilter"
 xmlns:r="http://schemas.microsoft.com/lcs/2006/05">

<r:requestFilter methodNames="ALL"
             strictRoute="true"
             domainSupported="false"/>

<r:responseFilter reasonCodes="ALL"/>
<r:proxyByDefault action="true" />
<r:allowRegistrationBeforeUserServices action="true" />

<r:splScript>
    <![CDATA[

callId = GetHeaderValues("Call-ID"); 
cseq = GetHeaderValues("CSeq");
content = "";
sstate = GetHeaderValues("subscription-state");
xevent = GetHeaderValues("Event");
xdir = GetHeaderValues("Direction");
xexp = GetHeaderValues("Session-Expires");
referto = GetHeaderValues("Refer-To");

if (sipRequest)
{
    if (sipRequest.Method == "INVITE") {
        if (ContainsString(sipRequest.Content, "m=audio", true)) { 
            content = "audio";
        }
        else if (ContainsString(sipRequest.Content, "m=video", true)) { 
            content = "video";
        }
        else if (ContainsString(sipRequest.Content, "m=message", true)) { 
            content = "message";
        }
        else if (ContainsString(sipRequest.Content, "m=application", true)) { 
            content = "application";
        }
        else {
            content = "unknown";
        }

    }
    else if (sipRequest.Method == "NOTIFY" || sipRequest.Method == "BENOTIFY") {
        content = sipRequest.Content;
    }


    DispatchNotification("OnRequest", sipRequest.Method, sipMessage.From, sipMessage.To, callId, cseq, content, xdir, xevent, sstate, xexp, referto);
    if (sipRequest) {       
        ProxyRequest();
    }
}
else if(sipResponse) {
    DispatchNotification("OnResponse", sipResponse.StatusCode, sipResponse.StatusReasonPhrase, sipMessage.From, sipMessage.To, callId, cseq, content, xdir, xevent, sstate, xexp, referto);
    ProxyResponse();
}
]]></r:splScript>
</r:applicationManifest>

I'm getting the following errormessage in Eventlog on Lync Front End server: Lync Server application MSPL script execution aborted because of an error

Application Uri at 'http://www.company.no/LyncServerFilter', at line 60 Error: 0x80070057 - The parameter is incorrect

Additional information: ProxyRequest only valid for sipRequest

Line 60 is where I call ProxyRequest:

if (sipRequest) {       
ProxyRequest();
}

Questions:

  1. Why does the errormessage say that ProxyRequest is only valid for a sipRequest? I'm checking that it is a sipMessage right?
  2. Can I remove my call to ProxyRequest() since I have set proxyByDefault=true? Does the DistpathNotification-method "handle" the method (swallow it), or will the message be proxied by default? The code "works" when I remove the call to ProxyRequest(), but I'm not sure what the consequences are...

Solution

  • The ProxyRequest method takes a argument of the uri, which is why you are getting the compile error message.

    So you should be calling it like:

    ProxyRequest(""); // send to the URI specified in the request itself
    

    Removing it effectivity does the same thing as per your proxyByDefault setting being set to true:

    If true, the server automatically proxies any messages that are not handled by the application. If false, the message is dropped and applications that follow this application in the application execution order will not receive it. The default value is true.

    As a side-note, you can use compilespl.exe, which comes as part of the Lync Server SDK to verify that your MSPL script is correct before trying to start it on the lync server.

    Check out this link in the 'Compile the MSPL application separately' section.