RPC error - The protocol sequence is not valid.

In the following example,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
status = RpcStringBindingCompose(	 // The RpcStringBindingCompose function creates a string binding handle.
NULL,
(RPC_WSTR)"ncacn_ip_tcp" ,
(RPC_WSTR)"192.168.1.2",
(RPC_WSTR)"2000",
NULL,
&stringBinding
);
if(status==RPC_S_OK) RhinoApp().Print("RpcStringBindingCompose = SUCCESS!!!\n");

RPC_BINDING_HANDLE ProgHandle;

status = RpcBindingFromStringBinding(
stringBinding,
&ProgHandle	 //server binding handle
);
if(status==RPC_S_OK) RhinoApp().Print("RpcBindingFromStringBinding = SUCCESS!!!\n");
if(status==RPC_S_INVALID_RPC_PROTSEQ) RhinoApp().Print("RpcBindingFromStringBinding = The protocol sequence is not valid.\n");


why is it that RpcStringBindingCompose returns "SUCCESS!!!" while RpcBindingFromStringBinding returns "The protocol sequence is not valid."
Last edited on
Use code brackets:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
status = RpcStringBindingCompose( // The RpcStringBindingCompose function creates a string binding handle.
NULL,
(RPC_WSTR)"ncacn_ip_tcp" ,
(RPC_WSTR)"192.168.1.2",
(RPC_WSTR)"111",
NULL,
&stringBinding
);
if(status==RPC_S_OK) RhinoApp().Print("RpcStringBindingCompose = SUCCESS!!!\n");

RPC_BINDING_HANDLE ProgHandle;

status = RpcBindingFromStringBinding(
stringBinding,
&ProgHandle //server binding handle
);
if(status==RPC_S_OK) RhinoApp().Print("RpcBindingFromStringBinding = SUCCESS!!!\n");
if(status==RPC_S_INVALID_STRING_BINDING) RhinoApp().Print("RpcBindingFromStringBinding = The string binding is not valid.\n");
if(status==RPC_S_PROTSEQ_NOT_SUPPORTED) RhinoApp().Print("RpcBindingFromStringBinding = Protocol sequence not supported on this host.\n");
if(status==RPC_S_INVALID_RPC_PROTSEQ) RhinoApp().Print("RpcBindingFromStringBinding = The protocol sequence is not valid.\n");
if(status==RPC_S_INVALID_ENDPOINT_FORMAT) RhinoApp().Print("RpcBindingFromStringBinding = The endpoint format is not valid.\n");
if(status==RPC_S_STRING_TOO_LONG) RhinoApp().Print("RpcBindingFromStringBinding = String too long.\n");
if(status==RPC_S_INVALID_NET_ADDR) RhinoApp().Print("RpcBindingFromStringBinding = The network address is not valid.\n");
if(status==RPC_S_INVALID_ARG) RhinoApp().Print("RpcBindingFromStringBinding = The argument was not valid.\n");
if(status==RPC_S_INVALID_NAF_ID) RhinoApp().Print("RpcBindingFromStringBinding = The network address family identifier is not valid.\n");
Update:
I have performed some diagnostics of my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Form the Manual Binding

	RPC_STATUS status;

	RPC_WSTR stringBinding = NULL;		
	RPC_WSTR ObjectUuid = NULL;
	RPC_WSTR ProtSeq = NULL;
	RPC_WSTR NetworkAddr = NULL;
	RPC_WSTR EndPoint = NULL;
	RPC_WSTR NetworkOptions = NULL;

	status = RpcStringBindingCompose(
		NULL,
		(RPC_WSTR)"ncacn_ip_tcp",
		(RPC_WSTR)"192.168.1.2",
		(RPC_WSTR)"2000",
		NULL,
		&stringBinding
		);
	if(status==RPC_S_OK) RhinoApp().Print("RpcStringBindingCompose = SUCCESS!!!\n");

	status = RpcStringBindingParse(				
		stringBinding,
		&ObjectUuid,
		&ProtSeq,
		&NetworkAddr,
		&EndPoint,
		&NetworkOptions
	);
	if(status==RPC_S_OK)				RhinoApp().Print("RpcStringBindingParse = SUCCESS!!!\n");
	if(status==RPC_S_INVALID_STRING_BINDING)	RhinoApp().Print("RpcStringBindingParse = The string binding is not valid.\n");

RhinoApp().Print("ObjectUuid =\t");
RhinoApp().Print((char*)ObjectUuid);
RhinoApp().Print("\n");
RhinoApp().Print("ProtSeq =\t");
RhinoApp().Print((char*)ProtSeq);
RhinoApp().Print("\n");
RhinoApp().Print("NetworkAddr =\t");
RhinoApp().Print((char*)NetworkAddr);
RhinoApp().Print("\n");
RhinoApp().Print("EndPoint =\t");
RhinoApp().Print((char*)EndPoint);
RhinoApp().Print("\n");
RhinoApp().Print("NetworkOptions =\t");
RhinoApp().Print((char*)NetworkOptions);
RhinoApp().Print("\n");
RhinoApp().Print("\n");

	RPC_PROTSEQ_VECTORA *ProtSeqVector = NULL;
	status = RpcNetworkInqProtseqsA(&ProtSeqVector);
	if(status==RPC_S_OK)				RhinoApp().Print("RpcNetworkInqProtseqs = SUCCESS!!!\n");
	if(status==RPC_S_NO_PROTSEQS)			RhinoApp().Print("RpcNetworkInqProtseqs = No supported protocol sequences.\n");

	int pCount = ProtSeqVector->Count;
	for (int i = 0; i < pCount; ++i)		
    {
RhinoApp().Print("Protseq = ");
RhinoApp().Print((char*)ProtSeqVector->Protseq[i]);
RhinoApp().Print("\n");
    }

	RPC_BINDING_HANDLE *ProgHandle;

	status = RpcBindingFromStringBinding(
		stringBinding,						
		ProgHandle
		);
	if(status==RPC_S_OK)				RhinoApp().Print("RpcBindingFromStringBinding = SUCCESS!!!\n");
	if(status==RPC_S_INVALID_STRING_BINDING)	RhinoApp().Print("RpcBindingFromStringBinding = The string binding is not valid.\n");
	if(status==RPC_S_PROTSEQ_NOT_SUPPORTED)		RhinoApp().Print("RpcBindingFromStringBinding = Protocol sequence not supported on this host.\n");
	if(status==RPC_S_INVALID_RPC_PROTSEQ)		RhinoApp().Print("RpcBindingFromStringBinding = The protocol sequence is not valid.\n");
	if(status==RPC_S_INVALID_ENDPOINT_FORMAT)	RhinoApp().Print("RpcBindingFromStringBinding = The endpoint format is not valid.\n");
	if(status==RPC_S_STRING_TOO_LONG)		RhinoApp().Print("RpcBindingFromStringBinding = String too long.\n");
	if(status==RPC_S_INVALID_NET_ADDR)		RhinoApp().Print("RpcBindingFromStringBinding = The network address is not valid.\n");
	if(status==RPC_S_INVALID_ARG)			RhinoApp().Print("RpcBindingFromStringBinding = The argument was not valid.\n");
	if(status==RPC_S_INVALID_NAF_ID)		RhinoApp().Print("RpcBindingFromStringBinding = The network address family identifier is not valid.\n");
	


and this is what I get:

RpcStringBindingCompose = SUCCESS!!!
RpcStringBindingParse = SUCCESS!!!
ObjectUuid =
ProtSeq = ncacn_ip_tcp
NetworkAddr = 192.168.1.2
EndPoint = 2000
NetworkOptions =

RpcNetworkInqProtseqs = SUCCESS!!!
Protseq = ncacn_np
Protseq = ncalrpc
Protseq = ncacn_ip_tcp
Protseq = ncadg_ip_udp
Protseq = ncacn_http
RpcBindingFromStringBinding = The protocol sequence is not valid.


Please note the last line should read "RpcBindingFromStringBinding = SUCCESS!!!"
Why is my Protocol not valid.


Problem solved in another post!!!

Add 'A' to the end of the RPC functions to accept ANSI values (as opposed to wide values) and change the RPC_WSTR calls to RPC_CSTR and BADDA BING!
Topic archived. No new replies allowed.